mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-16 12:26:30 +00:00
Update doc with new escaping behavior
When applied on ternary statements
This commit is contained in:
committed by
Fabien Potencier
parent
1a874b581a
commit
92e1cd35c5
+3
-5
@@ -416,7 +416,7 @@ The escaping rules are implemented as follows:
|
|||||||
{% set text = "Twig<br />" %}
|
{% set text = "Twig<br />" %}
|
||||||
{{ text }} {# will be escaped #}
|
{{ 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:
|
are never automatically escaped:
|
||||||
|
|
||||||
.. code-block:: twig
|
.. code-block:: twig
|
||||||
@@ -424,14 +424,12 @@ The escaping rules are implemented as follows:
|
|||||||
{{ foo ? "Twig<br />" : "<br />Twig" }} {# won't be escaped #}
|
{{ foo ? "Twig<br />" : "<br />Twig" }} {# won't be escaped #}
|
||||||
|
|
||||||
{% set text = "Twig<br />" %}
|
{% 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 />" %}
|
{% set text = "Twig<br />" %}
|
||||||
{{ foo ? text|raw : "<br />Twig" }} {# won't be escaped #}
|
{{ 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:
|
* Escaping is applied before printing, after any other filter is applied:
|
||||||
|
|
||||||
.. code-block:: twig
|
.. code-block:: twig
|
||||||
|
|||||||
Reference in New Issue
Block a user