public function register($ant) { $ant->bind('build', function ($content) { $haml = new HamlPHP(); return $haml->parseString($content); }); }
public function __construct() { $this->evaluator = new ContentEvaluator(); $hamlPHP = new HamlPHP(new FileStorage(dirname(__FILE__) . '/tmp/')); $hamlPHP->disableCache(); $this->compiler = $hamlPHP->getCompiler(); }
/** * Renders a template using Haml.php. * * @see View::render() * @throws RuntimeException If Haml lib directory does not exist. * @param string $template The template name specified in Slim::render() * @return string */ public function render($template) { if (!is_dir(self::$hamlDirectory)) { throw new RuntimeException('Cannot set the HamlPHP lib directory : ' . self::$hamlDirectory . '. Directory does not exist.'); } require_once self::$hamlDirectory . '/HamlPHP/HamlPHP.php'; require_once self::$hamlDirectory . '/HamlPHP/Storage/FileStorage.php'; $parser = new HamlPHP(new FileStorage(self::$hamlCacheDirectory)); return $parser->parseFile(self::$hamlTemplatesDirectory . $template, $this->data); }
public function testReadmeExample() { require_once HAMLPHP_ROOT . 'HamlPHP.php'; require_once HAMLPHP_ROOT . 'Storage/FileStorage.php'; // Make sure that a directory _tmp_ exists in your application and it is writable. $parser = new HamlPHP(new FileStorage(TEST_TMP_DIR)); $actual = $parser->parseFile($this->getTemplatePath('readme_example')); $expected = $this->getExpectedResult('readme_example'); $actual = $this->evaluator->evaluate($actual); $expected = $this->evaluator->evaluate($expected); $this->compareXmlStrings($expected, $actual); }
<?php require_once 'lib/HamlPHP/HamlPHP.php'; require_once 'lib/HamlPHP/Storage/FileStorage.php'; // Make sure that a directory _tmp_ exists in your application and it is writable. $parser = new HamlPHP(new FileStorage(dirname(__FILE__) . '/tmp/')); $content = $parser->parseFile('views/index.haml'); echo $parser->evaluate($content, array('foo' => '1'));
public static function getParsedResult($template) { $parser = new HamlPHP(self::getStorage()); //$parser->setIdGenerator(new FilePathIdGen()); $content = $parser->parseFile($template, array()); return $content; }
public function parseFile($fileName, array $variables = array()) { $mergedVariables = array_merge($this->globals, $variables); return parent::parseFile($this->viewPath . $fileName, $mergedVariables); }