Throw exception when something other than text or block tags are encountered inside of a parent tag. Other small cleanups

This commit is contained in:
Dan Miller
2014-04-09 16:15:05 +00:00
parent af8a62c5e2
commit d27840f8ef
4 changed files with 38 additions and 4 deletions
@@ -322,7 +322,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas
$this->assertEquals('hmm', $tpl->render($data));
}
public function IgnoreTextInsideSuperTemplates()
public function testIgnoreTextInsideSuperTemplates()
{
$partials = array(
'include' => '{{$foo}}default content{{/foo}}'
@@ -338,4 +338,27 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas
$this->assertEquals('default content', $tpl->render($data));
}
/**
* @expectedException Mustache_Exception_SyntaxException
* @expectedExceptionMessage Illegal content in < parent tag
*/
public function testOnlyBlockTagsAllowedInParent()
{
$partials = array(
'foo' => '{{$baz}}default content{{/baz}}'
);
$this->mustache->setPartials($partials);
$tpl = $this->mustache->loadTemplate(
'{{< foo }}{{# bar }}{{$ baz }}{{/ baz }}{{/ bar }}{{/ foo }}'
);
$data = array(
'bar' => 'set by user'
);
$tpl->render($data);
}
}