$compiler->subcompile($this->getNode('body'));
if (null !== $this->getNode('parent')) {
- $compiler->write("\$this->getParent(\$context)->display(\$context, array_merge(\$this->blocks, \$blocks));\n");
+ if ($this->getNode('parent') instanceof Twig_Node_Expression_Constant) {
+ $compiler->write("\$this->parent");
+ } else {
+ $compiler->write("\$this->getParent(\$context)");
+ }
+ $compiler->raw("->display(\$context, array_merge(\$this->blocks, \$blocks));\n");
}
}
->write("parent::__construct(\$env);\n\n")
;
+ // parent
+ if (null === $this->getNode('parent')) {
+ $compiler->write("\$this->parent = false;\n\n");
+ } elseif ($this->getNode('parent') instanceof Twig_Node_Expression_Constant) {
+ $compiler
+ ->write("\$this->parent = \$this->env->loadTemplate(")
+ ->subcompile($this->getNode('parent'))
+ ->raw(");\n\n")
+ ;
+ }
+
$countTraits = count($this->getNode('traits'));
if ($countTraits) {
// traits
$compiler
->outdent()
->write(");\n\n")
- ;
-
- $compiler
->write("\$this->blocks = array_merge(\n")
->indent()
->write("\$this->traits,\n")
;
}
- public function compileDebugInfo(Twig_Compiler $compiler)
+ protected function compileDebugInfo(Twig_Compiler $compiler)
{
$compiler
->write("public function getDebugInfo()\n", "{\n")
;
}
- public function compileLoadTemplate(Twig_Compiler $compiler, $node, $var)
+ protected function compileLoadTemplate(Twig_Compiler $compiler, $node, $var)
{
if ($node instanceof Twig_Node_Expression_Constant) {
$compiler
protected function doDisplay(array \$context, array \$blocks = array())
{
\$context["macro"] = \$this->env->loadTemplate("foo.twig");
- \$this->getParent(\$context)->display(\$context, array_merge(\$this->blocks, \$blocks));
+ \$this->parent->display(\$context, array_merge(\$this->blocks, \$blocks));
}
public function getTemplateName()
protected function doDisplay(array \$context, array \$blocks = array())
{
\$this->checkSecurity();
- \$this->getParent(\$context)->display(\$context, array_merge(\$this->blocks, \$blocks));
+ \$this->parent->display(\$context, array_merge(\$this->blocks, \$blocks));
}
protected function checkSecurity() {