From ba88c755579c06e7ccb5ee73c6e27e88a1fed114 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 17 May 2013 12:06:31 +0200 Subject: [PATCH] fixed the include function when used in an assignment (closes #1095) --- CHANGELOG | 2 +- lib/Twig/Extension/Core.php | 2 +- .../Fixtures/functions/include/assignment.test | 13 +++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 test/Twig/Tests/Fixtures/functions/include/assignment.test diff --git a/CHANGELOG b/CHANGELOG index 4696b40..d0dfeb4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ * 1.13.1 (2013-XX-XX) - * n/a + * fixed the include function when used in an assignment * 1.13.0 (2013-05-10) diff --git a/lib/Twig/Extension/Core.php b/lib/Twig/Extension/Core.php index c3ca51a..2c2a96a 100644 --- a/lib/Twig/Extension/Core.php +++ b/lib/Twig/Extension/Core.php @@ -1295,7 +1295,7 @@ function twig_include(Twig_Environment $env, $context, $template, $variables = a } try { - return $env->resolveTemplate($template)->display($variables); + return $env->resolveTemplate($template)->render($variables); } catch (Twig_Error_Loader $e) { if (!$ignoreMissing) { throw $e; diff --git a/test/Twig/Tests/Fixtures/functions/include/assignment.test b/test/Twig/Tests/Fixtures/functions/include/assignment.test new file mode 100644 index 0000000..b7653b4 --- /dev/null +++ b/test/Twig/Tests/Fixtures/functions/include/assignment.test @@ -0,0 +1,13 @@ +--TEST-- +"include" function +--TEMPLATE-- +{% set tmp = include("foo.twig") %} + +FOO{{ tmp }}BAR +--TEMPLATE(foo.twig)-- +FOOBAR +--DATA-- +return array() +--EXPECT-- +FOO +FOOBARBAR -- 1.7.2.5