Closed lucassouza1 closed 12 years ago
@MichaelColeAmbiguity Please don't use issues closed 2 years ago during the first step of the development. Twig has dynamic inheritance now (but with a bug in it apparently)
@stof Awesome! Thanks! http://twig.sensiolabs.org/doc/tags/extends.html#dynamic-inheritance
This has been fixed ages ago in Twig 1.1.2 (see #395).
Dynamic inheritance works only if you use the template just once. If I use the same template with another value bindings as the template was already created, the parent attribute in template generated class is already set, causing an unexpected behavior, The behavior inside first if statement:
if (null === $this->parent) {
$this->parent = (("html/field/type/" . $this->getAttribute((isset($context['field']) ? $context['field'] : null), "type", array(), "any", false, 1)) . ".html");
if (!$this->parent instanceof Twig_Template) {
$this->parent = $this->env->loadTemplate($this->parent);
}
}
happens just once making inheritance dynamic just for the first time.
So, I believe that it's another functionality, maybe not a simple dynamic inheritance.
As I said, you are probably using a very old version of Twig. But since then, it has been fixed. So, any version newer than 1.1.1 will work as expected.
My local version was outdated. Everything is working fine on 1.7.
Sorry for the inconvenience!
I include a template that is a proxy to another:
but all instances use the same as the first item value. This happens because parent is created just once: ´´´php
´´´
There's a way to use dynamic inheritance?