fixed the include function when used in an assignment (closes #1095)
authorFabien Potencier <fabien.potencier@gmail.com>
Fri, 17 May 2013 10:06:31 +0000 (12:06 +0200)
committerFabien Potencier <fabien.potencier@gmail.com>
Fri, 17 May 2013 10:06:31 +0000 (12:06 +0200)
CHANGELOG
lib/Twig/Extension/Core.php
test/Twig/Tests/Fixtures/functions/include/assignment.test [new file with mode: 0644]

index 4696b40..d0dfeb4 100644 (file)
--- 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)
 
index c3ca51a..2c2a96a 100644 (file)
@@ -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 (file)
index 0000000..b7653b4
--- /dev/null
@@ -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