From: Fabien Potencier Date: Tue, 6 Jul 2010 11:48:59 +0000 (+0200) Subject: fixed inheritance bug (closes #81) X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=3601d729b33c0811316c0943e98c01908015ff9f;p=web%2Fkonrad%2Ftwig.git fixed inheritance bug (closes #81) --- diff --git a/lib/Twig/Template.php b/lib/Twig/Template.php index 389bd91..cdea823 100644 --- a/lib/Twig/Template.php +++ b/lib/Twig/Template.php @@ -22,6 +22,15 @@ abstract class Twig_Template implements Twig_TemplateInterface $this->blocks = array(); } + public function __clone() + { + foreach ($this->blocks as $name => $calls) { + foreach ($calls as $i => $call) { + $this->blocks[$name][$i][0] = $this; + } + } + } + public function getEnvironment() { return $this->env; diff --git a/test/Twig/Tests/Fixtures/tags/inheritance/nested_inheritance.test b/test/Twig/Tests/Fixtures/tags/inheritance/nested_inheritance.test new file mode 100644 index 0000000..71e3cdf --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/inheritance/nested_inheritance.test @@ -0,0 +1,16 @@ +--TEST-- +"extends" tag +--TEMPLATE-- +{% extends "layout.twig" %} +{% block inside %}INSIDE{% endblock inside %} +--TEMPLATE(layout.twig)-- +{% extends "base.twig" %} +{% block body %} + {% block inside '' %} +{% endblock body %} +--TEMPLATE(base.twig)-- +{% block body '' %} +--DATA-- +return array() +--EXPECT-- +INSIDE