【发布时间】:2011-05-26 07:52:37
【问题描述】:
所以:
我非常喜欢在 ruby 项目中使用 Haml,并且正在 PHP 中对其进行测试。我一直在尝试PhamlP,因为它看起来还没有死,而 phpHaml 和 pHaml 已经将近 4 年没有更新了。
现在,我遇到的问题是 PhamlP 正在解析的 php 代码在 HTML 中显示为 cmets 而不是执行。这是测试文件,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' 行没有被执行,它以某种方式作为注释传递到浏览器。
你是怎么解决这个问题的?
【问题讨论】: