我很喜歡在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