protected function compileGetParent(Twig_Compiler $compiler)
{
+ $compiler
+ ->write("protected function doGetParent(array \$context)\n", "{\n")
+ ->indent()
+ ->write("return ")
+ ;
+
if (null === $this->getNode('parent')) {
- return;
+ $compiler->raw("false");
+ } else {
+ $compiler->subcompile($this->getNode('parent'));
}
$compiler
- ->write("public function getParent(array \$context)\n", "{\n")
- ->indent()
- ->write("\$parent = ")
- ->subcompile($this->getNode('parent'))
->raw(";\n")
- ->write("if (\$parent instanceof Twig_Template) {\n")
- ->indent()
- ->write("\$name = \$parent->getTemplateName();\n")
- ->write("\$this->parent[\$name] = \$parent;\n")
- ->write("\$parent = \$name;\n")
- ->outdent()
- ->write("} elseif (!isset(\$this->parent[\$parent])) {\n")
- ->indent()
- ->write("\$this->parent[\$parent] = \$this->env->loadTemplate(\$parent);\n")
- ->outdent()
- ->write("}\n\n")
- ->write("return \$this->parent[\$parent];\n")
->outdent()
->write("}\n\n")
;
*/
public function getParent(array $context)
{
- return false;
+ $parent = $this->doGetParent($context);
+ if (false === $parent) {
+ return false;
+ } elseif ($parent instanceof Twig_Template) {
+ $name = $parent->getTemplateName();
+ $this->parent[$name] = $parent;
+ $parent = $name;
+ } elseif (!isset($this->parent[$parent])) {
+ $this->parent[$parent] = $this->env->loadTemplate($parent);
+ }
+
+ return $this->parent[$parent];
}
+ abstract protected function doGetParent(array $context);
+
/**
* 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())
{
\$context = array_merge(\$this->env->getGlobals(), \$context);
{
protected \$parent;
- public function getParent(array \$context)
+ protected function doGetParent(array \$context)
{
- \$parent = "layout.twig";
- if (\$parent instanceof Twig_Template) {
- \$name = \$parent->getTemplateName();
- \$this->parent[\$name] = \$parent;
- \$parent = \$name;
- } elseif (!isset(\$this->parent[\$parent])) {
- \$this->parent[\$parent] = \$this->env->loadTemplate(\$parent);
- }
-
- return \$this->parent[\$parent];
+ return "layout.twig";
}
protected function doDisplay(array \$context, array \$blocks = array())
{
protected \$parent;
- public function getParent(array \$context)
+ protected function doGetParent(array \$context)
{
- \$parent = ((true) ? ("foo") : ("foo"));
- if (\$parent instanceof Twig_Template) {
- \$name = \$parent->getTemplateName();
- \$this->parent[\$name] = \$parent;
- \$parent = \$name;
- } elseif (!isset(\$this->parent[\$parent])) {
- \$this->parent[\$parent] = \$this->env->loadTemplate(\$parent);
- }
-
- return \$this->parent[\$parent];
+ return ((true) ? ("foo") : ("foo"));
}
protected function doDisplay(array \$context, array \$blocks = array())
/* 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();
{
protected \$parent;
- public function getParent(array \$context)
+ protected function doGetParent(array \$context)
{
- \$parent = "layout.twig";
- if (\$parent instanceof Twig_Template) {
- \$name = \$parent->getTemplateName();
- \$this->parent[\$name] = \$parent;
- \$parent = \$name;
- } elseif (!isset(\$this->parent[\$parent])) {
- \$this->parent[\$parent] = \$this->env->loadTemplate(\$parent);
- }
-
- return \$this->parent[\$parent];
+ return "layout.twig";
}
protected function doDisplay(array \$context, array \$blocks = array())
class Twig_TemplateTest extends Twig_Template
{
+ protected function doGetParent(array $context)
+ {
+ }
+
protected function doDisplay(array $context, array $blocks = array())
{
}