Skip to content

Commit

Permalink
Update doc with new escaping behavior
Browse files Browse the repository at this point in the history
When applied on ternary statements
  • Loading branch information
l-vo committed Dec 22, 2019
1 parent 37aa320 commit 93b8d8b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions doc/api.rst
Expand Up @@ -394,22 +394,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 #}
* Objects with a ``__toString`` method are converted to strings and
escaped. You can mark some classes and/or interfaces as being safe for some
strategies via ``EscaperExtension::addSafeClass()``:
Expand Down

0 comments on commit 93b8d8b

Please sign in to comment.