From 3601d729b33c0811316c0943e98c01908015ff9f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 6 Jul 2010 13:48:59 +0200 Subject: [PATCH] fixed inheritance bug (closes #81) --- lib/Twig/Template.php | 9 +++++++++ .../tags/inheritance/nested_inheritance.test | 16 ++++++++++++++++ 2 files changed, 25 insertions(+), 0 deletions(-) create mode 100644 test/Twig/Tests/Fixtures/tags/inheritance/nested_inheritance.test 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 -- 1.7.2.5