From: Fabien Potencier Date: Thu, 22 Sep 2011 09:51:27 +0000 (+0200) Subject: allowed empty templates to be used as traits X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=56f82db1a1cd26b3eaace6cd1a6d3daf18c37b76;p=web%2Fkonrad%2Ftwig.git allowed empty templates to be used as traits --- diff --git a/CHANGELOG b/CHANGELOG index dbe8f3e..231affd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +* 1.3.0 + + * allowed empty templates to be used as traits + * 1.2.0 (2011-09-13) no changes diff --git a/lib/Twig/Node/Module.php b/lib/Twig/Node/Module.php index 9b8c55e..1621232 100644 --- a/lib/Twig/Node/Module.php +++ b/lib/Twig/Node/Module.php @@ -255,6 +255,10 @@ class Twig_Node_Module extends Twig_Node } foreach ($nodes as $node) { + if (!count($node)) { + continue; + } + if ($node instanceof Twig_Node_Text && ctype_space($node->getAttribute('data'))) { continue; } diff --git a/test/Twig/Tests/Fixtures/tags/use/deep_empty.test b/test/Twig/Tests/Fixtures/tags/use/deep_empty.test new file mode 100644 index 0000000..05cca68 --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/use/deep_empty.test @@ -0,0 +1,10 @@ +--TEST-- +"use" tag +--TEMPLATE-- +{% use "foo.twig" %} +--TEMPLATE(foo.twig)-- +{% use "bar.twig" %} +--TEMPLATE(bar.twig)-- +--DATA-- +return array() +--EXPECT-- diff --git a/test/Twig/Tests/Node/ModuleTest.php b/test/Twig/Tests/Node/ModuleTest.php index d88124e..b2b2b86 100644 --- a/test/Twig/Tests/Node/ModuleTest.php +++ b/test/Twig/Tests/Node/ModuleTest.php @@ -88,7 +88,7 @@ class __TwigTemplate_be925a7b06dda0dfdbd18a1509f7eb34 extends Twig_Template public function isTraitable() { - return false; + return true; } } EOF diff --git a/test/Twig/Tests/Node/SandboxedModuleTest.php b/test/Twig/Tests/Node/SandboxedModuleTest.php index b1852a5..36ad98e 100644 --- a/test/Twig/Tests/Node/SandboxedModuleTest.php +++ b/test/Twig/Tests/Node/SandboxedModuleTest.php @@ -95,7 +95,7 @@ class __TwigTemplate_be925a7b06dda0dfdbd18a1509f7eb34 extends Twig_Template public function isTraitable() { - return false; + return true; } } EOF