So:
I quite like using Haml in ruby projects, and was testing it out in PHP. I’ve been trying PhamlP because it looks like it’s not dead, whereas phpHaml and pHaml haven’t been updated in nearly 4 years.
Now, the problem I have is the php code that PhamlP is parsing is showing up as comments in HTML instead of executing. Here’s the test file, index.php:
include_once('haml/HamlParser.php');
$haml = new HamlParser(array('ugly'=>'false'));
$page = $haml->parse('test.haml');
echo $page;
Here’s the test.haml file:
!!!
- $foo = 'bar'
%h1 Foo this
.test= $foo
and here’s the output I get in the browser when I view source:
<?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>
So, for instance, the line - $foo = 'bar' isn’t being executed, it’s somehow passing through to the browser as a comment.
How the heck do you fix that?
Don’t know it, but the obvious workaround would be to replace the
echo $pagewith:I’d assume
->parsedoes just a conversion, and the output is supposed to be stored in a new .php output/template/cache file usually.