From: Fabien Potencier Date: Tue, 24 Jan 2012 18:12:39 +0000 (+0100) Subject: tweaked previous merge (no need to duplicate visitors, handlers and the expression... X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=db9179c77d112bb0e1bf2944848915e67e5ca53b;p=web%2Fkonrad%2Ftwig.git tweaked previous merge (no need to duplicate visitors, handlers and the expression parser when parsing a template inside another one) --- diff --git a/lib/Twig/Parser.php b/lib/Twig/Parser.php index 4b85259..72d3637 100644 --- a/lib/Twig/Parser.php +++ b/lib/Twig/Parser.php @@ -64,17 +64,21 @@ class Twig_Parser implements Twig_ParserInterface { // push all variables into the stack to keep the current state of the parser $vars = get_object_vars($this); - unset($vars['stack'], $vars['env']); + unset($vars['stack'], $vars['env'], $vars['handlers'], $vars['visitors'], $vars['expressionParser']); $this->stack[] = $vars; $this->tmpVarCount = 0; // tag handlers - $this->handlers = $this->env->getTokenParsers(); - $this->handlers->setParser($this); + if (null === $this->handlers) { + $this->handlers = $this->env->getTokenParsers(); + $this->handlers->setParser($this); + } // node visitors - $this->visitors = $this->env->getNodeVisitors(); + if (null === $this->visitors) { + $this->visitors = $this->env->getNodeVisitors(); + } if (null === $this->expressionParser) { $this->expressionParser = new Twig_ExpressionParser($this, $this->env->getUnaryOperators(), $this->env->getBinaryOperators());