Add block functions to the template, so they can be evaluated lazily.

Fixes #264
This commit is contained in:
Damyon Wiese
2015-07-17 21:14:34 +08:00
parent 11ad87ae2d
commit 1e63ba5fd9
2 changed files with 55 additions and 10 deletions
@@ -467,6 +467,23 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas
$this->assertEquals('<1><2><3>', $tpl->render($data));
}
public function testInheritanceWithLazyEvaluationAndSections()
{
$partials = array(
'parent' => '{{#items}}{{$value}}\n\nignored {{.}} {{#more}} there is more {{/more}}\n\n{{/value}}{{/items}}',
);
$this->mustache->setPartials($partials);
$tpl = $this->mustache->loadTemplate(
'{{<parent}}\n\n\n{{$value}}<{{ . }}>{{#more}} there is less {{/more}}{{/value}}\n\n{{/parent}}'
);
$data = array('items' => array(1, 2, 3), 'more' => 'stuff');
$this->assertEquals('<1> there is less <2> there is less <3> there is less ', $tpl->render($data));
}
/**
* @dataProvider getIllegalInheritanceExamples
* @expectedException Mustache_Exception_SyntaxException