Skip to content

Commit

Permalink
minor #3224 Update doc with new escaping behavior on ternary statemen…
Browse files Browse the repository at this point in the history
…ts (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
  • Loading branch information
fabpot committed Dec 27, 2019
2 parents 1a874b5 + 92e1cd3 commit 8236277
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions doc/api.rst
Expand Up @@ -416,22 +416,20 @@ 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
{{ 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
Expand Down

0 comments on commit 8236277

Please sign in to comment.