}
}
+ $compiler
+ ->write("if (null === \$this->parent) {\n")
+ ->indent();
+ ;
+
if ($this->parent instanceof Twig_Node_Expression_Constant) {
$compiler
->write("\$this->parent = \$this->env->loadTemplate(")
$compiler
->write("\$this->parent->pushBlocks(\$this->blocks);\n")
+ ->outdent()
+ ->write("}\n")
->write("\$this->parent->display(\$context);\n")
;
} else {
public function display(array \$context)
{
\$context['macro'] = \$this->env->loadTemplate("foo.twig", true);
- \$this->parent = \$this->env->loadTemplate("layout.twig");
- \$this->parent->pushBlocks(\$this->blocks);
+ if (null === \$this->parent) {
+ \$this->parent = \$this->env->loadTemplate("layout.twig");
+ \$this->parent->pushBlocks(\$this->blocks);
+ }
\$this->parent->display(\$context);
}
public function display(array \$context)
{
- \$this->parent = (true) ? ("foo") : ("foo");
- if (!\$this->parent instanceof Twig_Template) {
- \$this->parent = \$this->env->loadTemplate(\$this->parent);
+ if (null === \$this->parent) {
+ \$this->parent = (true) ? ("foo") : ("foo");
+ if (!\$this->parent instanceof Twig_Template) {
+ \$this->parent = \$this->env->loadTemplate(\$this->parent);
+ }
+ \$this->parent->pushBlocks(\$this->blocks);
}
- \$this->parent->pushBlocks(\$this->blocks);
\$this->parent->display(\$context);
}
public function display(array \$context)
{
- \$this->parent = \$this->env->loadTemplate("layout.twig");
- \$this->parent->pushBlocks(\$this->blocks);
+ if (null === \$this->parent) {
+ \$this->parent = \$this->env->loadTemplate("layout.twig");
+ \$this->parent->pushBlocks(\$this->blocks);
+ }
\$this->parent->display(\$context);
}