From 1ac50758792868825752ccbe7ea47600903d4780 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 18 Feb 2011 16:13:23 +0100 Subject: [PATCH] updated documentation and added a unit test --- CHANGELOG | 1 + doc/templates.rst | 9 +++++++-- test/Twig/Tests/Fixtures/tags/set/basic.test | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 5f8964dd0c..b2751c3101 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ Changes: + * changed the way {% set %} works when capturing (the content is now marked as safe) * added support for macro name in the endmacro tag * fixed the "length" filter for numbers * removed coupling between Twig_Node and Twig_Template diff --git a/doc/templates.rst b/doc/templates.rst index efb15ac321..ef940e1a8e 100644 --- a/doc/templates.rst +++ b/doc/templates.rst @@ -724,7 +724,7 @@ You can also chain filters: SOME TEXT {% endfilter %} -It should returns ``<strong>some text</strong>``. +It should return ``<strong>some text</strong>``. Assignments ~~~~~~~~~~~ @@ -744,7 +744,7 @@ the ``set`` tag and can have multiple targets: {% set foo, bar = 'foo', 'bar' %} -The ``set`` tag can also be used to 'capture' chunks of HTML: +The ``set`` tag can also be used to 'capture' chunks of text: .. code-block:: jinja @@ -754,6 +754,11 @@ The ``set`` tag can also be used to 'capture' chunks of HTML: {% endset %} +.. caution:: + + If you enable automatic output escaping, Twig will only consider the + content to be safe when capturing chunks of text. + Extends ~~~~~~~ diff --git a/test/Twig/Tests/Fixtures/tags/set/basic.test b/test/Twig/Tests/Fixtures/tags/set/basic.test index 75ad6d3953..a5a9f830ec 100644 --- a/test/Twig/Tests/Fixtures/tags/set/basic.test +++ b/test/Twig/Tests/Fixtures/tags/set/basic.test @@ -2,8 +2,10 @@ "set" tag --TEMPLATE-- {% set foo = 'foo' %} +{% set bar = 'foo
' %} {{ foo }} +{{ bar }} {% set foo, bar = 'foo', 'bar' %} @@ -12,6 +14,7 @@ return array() --EXPECT-- foo +foo<br /> foobar