fixed inheritance

This commit is contained in:
Fabien Potencier
2010-06-29 16:28:02 +02:00
parent 80af31538a
commit 478fe2ed18
5 changed files with 22 additions and 5 deletions
+1
View File
@@ -3,6 +3,7 @@
Backward incompatibilities:
* the self special variable has been renamed to _self
* fixed inheritance
* added the special _context variable to reference the current context
* renamed self to _self (to avoid conflict)
* fixed Twig_Template::getAttribute() for protected properties
+2 -2
View File
@@ -72,7 +72,7 @@ class Twig_Node_Module extends Twig_Node
if ($this->parent instanceof Twig_Node_Expression_Constant) {
$compiler
->write("\$this->parent = \$this->env->loadTemplate(")
->write("\$this->parent = clone \$this->env->loadTemplate(")
->subcompile($this->parent)
->raw(");\n")
;
@@ -84,7 +84,7 @@ class Twig_Node_Module extends Twig_Node
->write("if (!\$this->parent")
->raw(" instanceof Twig_Template) {\n")
->indent()
->write("\$this->parent = \$this->env->loadTemplate(\$this->parent);\n")
->write("\$this->parent = clone \$this->env->loadTemplate(\$this->parent);\n")
->outdent()
->write("}\n")
;
@@ -0,0 +1,16 @@
--TEST--
"extends" tag
--TEMPLATE--
{% extends "base.twig" %}
{% block content %}{% include "included.twig" %}{% endblock %}
{% block footer %}Footer{% endblock %}
--TEMPLATE(included.twig)--
{% extends "base.twig" %}
{% block content %}{% endblock %}
--TEMPLATE(base.twig)--
{% block content %}{% endblock %}
{% block footer %}{% endblock %}
--DATA--
return array()
--EXPECT--
Footer
+2 -2
View File
@@ -94,7 +94,7 @@ class __TwigTemplate_be925a7b06dda0dfdbd18a1509f7eb34 extends Twig_Template
{
\$context['macro'] = \$this->env->loadTemplate("foo.twig", true);
if (null === \$this->parent) {
\$this->parent = \$this->env->loadTemplate("layout.twig");
\$this->parent = clone \$this->env->loadTemplate("layout.twig");
\$this->parent->pushBlocks(\$this->blocks);
}
\$this->parent->display(\$context);
@@ -126,7 +126,7 @@ class __TwigTemplate_be925a7b06dda0dfdbd18a1509f7eb34 extends Twig_Template
if (null === \$this->parent) {
\$this->parent = (true) ? ("foo") : ("foo");
if (!\$this->parent instanceof Twig_Template) {
\$this->parent = \$this->env->loadTemplate(\$this->parent);
\$this->parent = clone \$this->env->loadTemplate(\$this->parent);
}
\$this->parent->pushBlocks(\$this->blocks);
}
+1 -1
View File
@@ -102,7 +102,7 @@ class __TwigTemplate_be925a7b06dda0dfdbd18a1509f7eb34 extends Twig_Template
public function display(array \$context)
{
if (null === \$this->parent) {
\$this->parent = \$this->env->loadTemplate("layout.twig");
\$this->parent = clone \$this->env->loadTemplate("layout.twig");
\$this->parent->pushBlocks(\$this->blocks);
}
\$this->parent->display(\$context);