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
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")
;
->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")
;
--- /dev/null
+--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
{
\$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);
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);
}
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);