Browse code

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

Fabien Potencier authored on 27/12/2019 07:28:59
Showing 1 changed files
... ...
@@ -416,7 +416,7 @@ The escaping rules are implemented as follows:
416 416
         {% set text = "Twig<br />" %}
417 417
         {{ text }} {# will be escaped #}
418 418
 
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
420 420
   are never automatically escaped:
421 421
 
422 422
   .. code-block:: twig
... ...
@@ -424,14 +424,12 @@ The escaping rules are implemented as follows:
424 424
         {{ foo ? "Twig<br />" : "<br />Twig" }} {# won't be escaped #}
425 425
 
426 426
         {% 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 #}
428 429
 
429 430
         {% set text = "Twig<br />" %}
430 431
         {{ foo ? text|raw : "<br />Twig" }} {# won't be escaped #}
431 432
 
432
-        {% set text = "Twig<br />" %}
433
-        {{ foo ? text|escape : "<br />Twig" }} {# the result of the expression won't be escaped #}
434
-
435 433
 * Escaping is applied before printing, after any other filter is applied:
436 434
 
437 435
   .. code-block:: twig