Skip to content

Commit 8236277

Browse files
committed
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 ------- 92e1cd3 Update doc with new escaping behavior
2 parents 1a874b5 + 92e1cd3 commit 8236277

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

doc/api.rst

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -416,22 +416,20 @@ The escaping rules are implemented as follows:
416416
{% set text = "Twig<br />" %}
417417
{{ text }} {# will be escaped #}
418418
419-
* Expressions which the result is always a literal or a variable marked safe
419+
* Expressions which the result is a literal or a variable marked safe
420420
are never automatically escaped:
421421

422422
.. code-block:: twig
423423
424424
{{ foo ? "Twig<br />" : "<br />Twig" }} {# won't be escaped #}
425425
426426
{% set text = "Twig<br />" %}
427-
{{ foo ? text : "<br />Twig" }} {# will be escaped #}
427+
{{ true ? text : "<br />Twig" }} {# will be escaped #}
428+
{{ false ? text : "<br />Twig" }} {# won't be escaped #}
428429
429430
{% set text = "Twig<br />" %}
430431
{{ foo ? text|raw : "<br />Twig" }} {# won't be escaped #}
431432
432-
{% set text = "Twig<br />" %}
433-
{{ foo ? text|escape : "<br />Twig" }} {# the result of the expression won't be escaped #}
434-
435433
* Escaping is applied before printing, after any other filter is applied:
436434

437435
.. code-block:: twig

0 commit comments

Comments
 (0)