mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-14 11:27:00 +00:00
fixed inheritance
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user