Lazily evaluate blocks pragmas.
The specific example in the docs page about what does not work, is exactly what we need to make this useful. Fixes #264
This commit is contained in:
@@ -433,6 +433,40 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas
|
||||
$this->assertEquals('default content', $tpl->render($data));
|
||||
}
|
||||
|
||||
public function testInheritanceWithLazyEvaluation()
|
||||
{
|
||||
$partials = array(
|
||||
'parent' => '{{#items}}{{$value}}ignored{{/value}}{{/items}}',
|
||||
);
|
||||
|
||||
$this->mustache->setPartials($partials);
|
||||
|
||||
$tpl = $this->mustache->loadTemplate(
|
||||
'{{<parent}}{{$value}}<{{ . }}>{{/value}}{{/parent}}'
|
||||
);
|
||||
|
||||
$data = array('items' => array(1, 2, 3));
|
||||
|
||||
$this->assertEquals('<1><2><3>', $tpl->render($data));
|
||||
}
|
||||
|
||||
public function testInheritanceWithLazyEvaluationWhitespaceIgnored()
|
||||
{
|
||||
$partials = array(
|
||||
'parent' => '{{#items}}{{$value}}\n\nignored\n\n{{/value}}{{/items}}',
|
||||
);
|
||||
|
||||
$this->mustache->setPartials($partials);
|
||||
|
||||
$tpl = $this->mustache->loadTemplate(
|
||||
'{{<parent}}\n\n\n{{$value}}<{{ . }}>{{/value}}\n\n{{/parent}}'
|
||||
);
|
||||
|
||||
$data = array('items' => array(1, 2, 3));
|
||||
|
||||
$this->assertEquals('<1><2><3>', $tpl->render($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getIllegalInheritanceExamples
|
||||
* @expectedException Mustache_Exception_SyntaxException
|
||||
|
||||
Reference in New Issue
Block a user