From 01b8c7cfae6e9704f748046371179101fdf19624 Mon Sep 17 00:00:00 2001 From: nikic <+@ni-po.com> Date: Wed, 9 Feb 2011 18:27:28 +0100 Subject: [PATCH] capturing {% set %} should give Twig_Markup --- lib/Twig/Node/Set.php | 2 +- test/Twig/Tests/Fixtures/tags/set/capture.test | 4 ++-- test/Twig/Tests/Node/SetTest.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Twig/Node/Set.php b/lib/Twig/Node/Set.php index 04be00e..9dae2ea 100644 --- a/lib/Twig/Node/Set.php +++ b/lib/Twig/Node/Set.php @@ -52,7 +52,7 @@ class Twig_Node_Set extends Twig_Node $compiler->subcompile($this->getNode('names'), false); if ($this->getAttribute('capture')) { - $compiler->raw(" = ob_get_clean()"); + $compiler->raw(" = new Twig_Markup(ob_get_clean())"); } } diff --git a/test/Twig/Tests/Fixtures/tags/set/capture.test b/test/Twig/Tests/Fixtures/tags/set/capture.test index 4408ca8..f156a1a 100644 --- a/test/Twig/Tests/Fixtures/tags/set/capture.test +++ b/test/Twig/Tests/Fixtures/tags/set/capture.test @@ -1,10 +1,10 @@ --TEST-- "set" tag block capture --TEMPLATE-- -{% set foo %}foo{% endset %} +{% set foo %}f
o
o{% endset %} {{ foo }} --DATA-- return array() --EXPECT-- -foo +f
o
o diff --git a/test/Twig/Tests/Node/SetTest.php b/test/Twig/Tests/Node/SetTest.php index 7883fba..6f61922 100644 --- a/test/Twig/Tests/Node/SetTest.php +++ b/test/Twig/Tests/Node/SetTest.php @@ -51,7 +51,7 @@ class Twig_Tests_Node_SetTest extends Twig_Tests_Node_TestCase $tests[] = array($node, <<