我很喜欢在Ruby项目中使用Haml,并在PHP中进行测试。我一直在尝试PhamlP,因为它看起来并没有死亡,而phpHaml和pHaml在近4年内还没有更新。
现在,我遇到的问题是PhamlP解析的php代码显示为HTML中的注释而不是执行。下面是测试文件,index.php文件:
include_once('haml/HamlParser.php');
$haml = new HamlParser(array('ugly'=>'false'));
$page = $haml->parse('test.haml');
echo $page;
这里的test.haml文件:
!!!
- $foo = 'bar'
%h1 Foo this
.test= $foo
和这里的输出我在浏览器中得到,当我查看源代码:
<?php
require_once '/Users/Andrew/Sites/eighty-b/_app/haml/HamlHelpers.php';
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php $foo = 'bar'; ?><h1>Foo this</h1><div class="bar">This better fooacross multiple lines butstill in the bar div!</div><div class="test"><?php echo $foo; ?></div>
因此,例如,行- $foo = 'bar'
没有被执行,它以某种方式传递给浏览器作为注释。
你是怎么修好的?
是的,这固定它...似乎笨重,但它的作品。 – Andrew 2010-12-17 05:19:46