macros imported "globally" in a template are now available in macros without re-importing them

This commit is contained in:
Fabien Potencier
2019-05-16 14:43:12 +02:00
parent cd49c5d44b
commit e138164015
21 changed files with 108 additions and 42 deletions
+3 -1
View File
@@ -166,7 +166,8 @@ class ModuleNode extends Node
->raw(sprintf(" extends %s\n", $compiler->getEnvironment()->getBaseTemplateClass(false)))
->write("{\n")
->indent()
->write("private \$source;\n\n")
->write("private \$source;\n")
->write("private \$macros = [];\n\n")
;
}
@@ -310,6 +311,7 @@ class ModuleNode extends Node
$compiler
->write("protected function doDisplay(array \$context, array \$blocks = [])\n", "{\n")
->indent()
->write("\$macros = \$this->macros;\n")
->subcompile($this->getNode('display_start'))
->subcompile($this->getNode('body'))
;