ensured that each template (Twig_Node_Module) is only visited once

This commit is contained in:
Fabien Potencier
2012-04-25 09:17:16 +02:00
parent ac7907abab
commit feaaca216c
2 changed files with 4 additions and 3 deletions
+3 -2
View File
@@ -20,7 +20,8 @@ class Twig_Node_Module extends Twig_Node
{
public function __construct(Twig_NodeInterface $body, Twig_Node_Expression $parent = null, Twig_NodeInterface $blocks, Twig_NodeInterface $macros, Twig_NodeInterface $traits, Twig_NodeInterface $embeddedTemplates, $filename)
{
parent::__construct(array('parent' => $parent, 'body' => $body, 'blocks' => $blocks, 'macros' => $macros, 'traits' => $traits, 'embedded_templates' => $embeddedTemplates), array('filename' => $filename, 'index' => null), 1);
// embedded templates are set as attributes so that they are only visited once by the visitors
parent::__construct(array('parent' => $parent, 'body' => $body, 'blocks' => $blocks, 'macros' => $macros, 'traits' => $traits), array('filename' => $filename, 'index' => null, 'embedded_templates' => $embeddedTemplates), 1);
}
public function setIndex($index)
@@ -37,7 +38,7 @@ class Twig_Node_Module extends Twig_Node
{
$this->compileTemplate($compiler);
foreach ($this->getNode('embedded_templates') as $template) {
foreach ($this->getAttribute('embedded_templates') as $template) {
$compiler->subcompile($template);
}
}
+1 -1
View File
@@ -24,7 +24,7 @@ class Twig_Node_SandboxedModule extends Twig_Node_Module
public function __construct(Twig_Node_Module $node, array $usedFilters, array $usedTags, array $usedFunctions)
{
parent::__construct($node->getNode('body'), $node->getNode('parent'), $node->getNode('blocks'), $node->getNode('macros'), $node->getNode('traits'), $node->getNode('embedded_templates'), $node->getAttribute('filename'), $node->getLine(), $node->getNodeTag());
parent::__construct($node->getNode('body'), $node->getNode('parent'), $node->getNode('blocks'), $node->getNode('macros'), $node->getNode('traits'), $node->getAttribute('embedded_templates'), $node->getAttribute('filename'), $node->getLine(), $node->getNodeTag());
$this->setAttribute('index', $node->getAttribute('index'));