More correct sections implementation.
Allows nested sections of the same name, throws exceptions on incorrectly nested sections, e.g.:
{{#foo}}{{#bar}}{{/foo}}{{/bar}}
Add a set of tests for incorrectly nested sections.
This commit is contained in:
@@ -333,4 +333,24 @@ class MustacheTest extends PHPUnit_Framework_TestCase {
|
||||
$this->assertEquals('success', $m->render('{{=<< >>=}}<< result >>'));
|
||||
$this->assertEquals('success', $m->render('{{=<% %>=}}<% result %>'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group sections
|
||||
* @dataProvider poorlyNestedSections
|
||||
* @expectedException MustacheException
|
||||
*/
|
||||
public function testPoorlyNestedSections($template) {
|
||||
$m = new Mustache($template);
|
||||
$m->render();
|
||||
}
|
||||
|
||||
public function poorlyNestedSections() {
|
||||
return array(
|
||||
array('{{#foo}}'),
|
||||
array('{{#foo}}{{/bar}}'),
|
||||
array('{{#foo}}{{#bar}}{{/foo}}'),
|
||||
array('{{#foo}}{{#bar}}{{/foo}}{{/bar}}'),
|
||||
array('{{#foo}}{{/bar}}{{/foo}}'),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user