Skip to content

Instantly share code, notes, and snippets.

@svallory
Created June 24, 2013 14:36
Show Gist options
  • Save svallory/5850495 to your computer and use it in GitHub Desktop.
Save svallory/5850495 to your computer and use it in GitHub Desktop.
How to render a partial using HamlPHP
<?php
// WARNING: This is the simplest possible example. It could be vastly improved
// by keeping the HamlPHP instance somewhere and, even more important, caching parser results
function render_partial($file, $data) {
$parser = new HamlPHP(new FileStorage('path/to/tmp/'));
$content = $parser->parseFile($file);
echo $parser->evaluateFile($content, $data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment