From 93f824d09aa8194960c6c1889fdbe17f0dfde5f3 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Tue, 9 Aug 2022 11:17:36 -0700 Subject: [PATCH] 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. --- src/Mustache/Parser.php | 6 ---- .../Test/Functional/DynamicPartialsTest.php | 28 ------------------- 2 files changed, 34 deletions(-) diff --git a/src/Mustache/Parser.php b/src/Mustache/Parser.php index de43fcd..02e3d89 100644 --- a/src/Mustache/Parser.php +++ b/src/Mustache/Parser.php @@ -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); } diff --git a/test/Mustache/Test/Functional/DynamicPartialsTest.php b/test/Mustache/Test/Functional/DynamicPartialsTest.php index 9887132..88e1fd8 100644 --- a/test/Mustache/Test/Functional/DynamicPartialsTest.php +++ b/test/Mustache/Test/Functional/DynamicPartialsTest.php @@ -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