From: Jannis Grimm Date: Mon, 25 Jul 2011 20:12:48 +0000 (+0200) Subject: Changed Module.php to pass existing tests X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=9822ac491eb29087615379cdefa80b3a95947765;p=web%2Fkonrad%2Ftwig.git Changed Module.php to pass existing tests --- 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() ;