minor #3224 Update doc with new escaping behavior on ternary statements (l-vo)

This PR was submitted for the 3.x branch but it was merged into the 1.x branch instead (closes #3224).

Discussion
----------

Update doc with new escaping behavior on ternary statements

According to https://symfony.com/blog/better-white-space-control-in-twig-templates#fine-grained-escaping-on-ternary-expressions

Commits
-------

92e1cd35 Update doc with new escaping behavior
This commit is contained in:
Fabien Potencier
2019-12-27 08:28:59 +01:00
+3 -5
View File
@@ -416,7 +416,7 @@ The escaping rules are implemented as follows:
{% set text = "Twig<br />" %}
{{ text }} {# will be escaped #}
* Expressions which the result is always a literal or a variable marked safe
* Expressions which the result is a literal or a variable marked safe
are never automatically escaped:
.. code-block:: twig
@@ -424,14 +424,12 @@ The escaping rules are implemented as follows:
{{ foo ? "Twig<br />" : "<br />Twig" }} {# won't be escaped #}
{% set text = "Twig<br />" %}
{{ foo ? text : "<br />Twig" }} {# will be escaped #}
{{ true ? text : "<br />Twig" }} {# will be escaped #}
{{ false ? text : "<br />Twig" }} {# won't be escaped #}
{% set text = "Twig<br />" %}
{{ foo ? text|raw : "<br />Twig" }} {# won't be escaped #}
{% set text = "Twig<br />" %}
{{ foo ? text|escape : "<br />Twig" }} {# the result of the expression won't be escaped #}
* Escaping is applied before printing, after any other filter is applied:
.. code-block:: twig