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:
Justin Hileman
2010-11-24 03:16:18 -05:00
parent 35c725089b
commit 38accdaf89
2 changed files with 89 additions and 14 deletions
+20
View File
@@ -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}}'),
);
}
}