From 9822ac491eb29087615379cdefa80b3a95947765 Mon Sep 17 00:00:00 2001 From: Jannis Grimm Date: Mon, 25 Jul 2011 22:12:48 +0200 Subject: [PATCH] Changed Module.php to pass existing tests --- lib/Twig/Node/Module.php | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/Twig/Node/Module.php b/lib/Twig/Node/Module.php index 5d319e6..7079227 100644 --- a/lib/Twig/Node/Module.php +++ b/lib/Twig/Node/Module.php @@ -72,7 +72,13 @@ class Twig_Node_Module extends Twig_Node ->write("\$parent = ") ->subcompile($this->getNode('parent')) ->raw(";\n") - ->write("if(!isset(\$this->parent[\$parent])) {\n") + ->write("if (\$parent instanceof Twig_Template) {\n") + ->indent() + ->write("\$name = \$parent->getTemplateName();\n") + ->write("\$this->parent[\$name] = \$parent;\n") + ->write("\$parent = \$name;\n") + ->outdent() + ->write("} elseif (!isset(\$this->parent[\$parent])) {\n") ->indent() ->write("\$this->parent[\$parent] = \$this->env->loadTemplate(\$parent);\n") ->outdent() @@ -126,6 +132,7 @@ class Twig_Node_Module extends Twig_Node ->write("public function __construct(Twig_Environment \$env)\n", "{\n") ->indent() ->write("parent::__construct(\$env);\n\n") + ->write("\$this->parent = array();\n") ; $countTraits = count($this->getNode('traits')); @@ -160,7 +167,6 @@ class Twig_Node_Module extends Twig_Node } $compiler - ->write("\$parent = array()") ->write("\$this->blocks = array_replace(\n") ->indent() ; -- 1.7.2.5