Remove exceptions on multiple * in dynamic names.
Per the finalized spec, these should be treated as lookup failures (i.e. rendered as empty strings) rather than exceptions.
This commit is contained in:
@@ -313,12 +313,6 @@ class Mustache_Parser
|
||||
$isDynamic = true;
|
||||
}
|
||||
|
||||
// Two stars is two many!
|
||||
if (preg_match('/^\s*\*\s*/', $name) || preg_match('/[|.]\s*\*/', $name)) {
|
||||
$msg = sprintf('Invalid dynamic name: %s', $name);
|
||||
throw new Mustache_Exception_SyntaxException($msg, $token);
|
||||
}
|
||||
|
||||
return array($name, $isDynamic);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,34 +24,6 @@ class Mustache_Test_Functional_DynamicPartialsTest extends PHPUnit_Framework_Tes
|
||||
));
|
||||
}
|
||||
|
||||
public function getInvalidDynamicNamesExamples()
|
||||
{
|
||||
return array(
|
||||
array('{{> **foo}}'),
|
||||
array('{{> *foo.*bar}}'),
|
||||
array('{{> foo.*bar}}'),
|
||||
array('{{ *foo }}'),
|
||||
array('{{{ *foo }}}'),
|
||||
array('{{& *foo }}'),
|
||||
array('{{# *foo }}{{/ *foo }}'),
|
||||
array('{{^ *foo }}{{/ *foo }}'),
|
||||
array('{{% FILTERS}}{{> *foo | *bar}}'),
|
||||
array('{{% FILTERS}}{{> foo | *bar}}'),
|
||||
array('{{% BLOCKS }}{{$ *foo }}{{/ *foo }}'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidDynamicNamesExamples
|
||||
* @expectedException Mustache_Exception_SyntaxException
|
||||
* @expectedExceptionMessage Invalid dynamic name:
|
||||
*/
|
||||
public function testInvalidDynamicNamesExamples($template)
|
||||
{
|
||||
$this->mustache->render($template);
|
||||
}
|
||||
|
||||
|
||||
public function getValidDynamicNamesExamples()
|
||||
{
|
||||
// technically not all dynamic names, but also not invalid
|
||||
|
||||
Reference in New Issue
Block a user