mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-16 12:26:30 +00:00
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:
+3
-5
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user