protected function compileGetParent(Twig_Compiler $compiler)
{
+ if (null === $this->getNode('parent')) {
+ return;
+ }
+
$compiler
->write("protected function doGetParent(array \$context)\n", "{\n")
->indent()
->write("return ")
;
- if (null === $this->getNode('parent')) {
- $compiler->raw("false");
+ if ($this->getNode('parent') instanceof Twig_Node_Expression_Constant) {
+ $compiler->subcompile($this->getNode('parent'));
} else {
- if ($this->getNode('parent') instanceof Twig_Node_Expression_Constant) {
- $compiler->subcompile($this->getNode('parent'));
- } else {
- $compiler
- ->raw("\$this->env->resolveTemplate(")
- ->subcompile($this->getNode('parent'))
- ->raw(")")
- ;
- }
+ $compiler
+ ->raw("\$this->env->resolveTemplate(")
+ ->subcompile($this->getNode('parent'))
+ ->raw(")")
+ ;
}
$compiler
}
}
+ if ($traitable) {
+ return;
+ }
+
$compiler
->write("public function isTraitable()\n", "{\n")
->indent()
return $this->parents[$parent];
}
- abstract protected function doGetParent(array $context);
+ protected function doGetParent(array $context)
+ {
+ return false;
+ }
+
+ public function isTraitable()
+ {
+ return true;
+ }
/**
* Displays a parent block.
/* foo.twig */
class __TwigTemplate_be925a7b06dda0dfdbd18a1509f7eb34 extends Twig_Template
{
- protected function doGetParent(array \$context)
- {
- return false;
- }
-
protected function doDisplay(array \$context, array \$blocks = array())
{
echo "foo";
return "foo.twig";
}
- public function isTraitable()
- {
- return true;
- }
}
EOF
, $twig);
/* foo.twig */
class __TwigTemplate_be925a7b06dda0dfdbd18a1509f7eb34 extends Twig_Template
{
- protected function doGetParent(array \$context)
- {
- return false;
- }
-
protected function doDisplay(array \$context, array \$blocks = array())
{
\$this->checkSecurity();
return "foo.twig";
}
- public function isTraitable()
- {
- return true;
- }
}
EOF
, $twig);