Browse code

Update doc with new escaping behavior

When applied on ternary statements

Laurent VOULLEMIER authored on 22/12/2019 08:16:04 • Fabien Potencier committed on 27/12/2019 07:28:48
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