Yaffs site version 1.1
[yaffs-website] / vendor / twig / twig / doc / filters / raw.rst
1 ``raw``
2 =======
3
4 The ``raw`` filter marks the value as being "safe", which means that in an
5 environment with automatic escaping enabled this variable will not be escaped
6 if ``raw`` is the last filter applied to it:
7
8 .. code-block:: jinja
9
10     {% autoescape %}
11         {{ var|raw }} {# var won't be escaped #}
12     {% endautoescape %}
13
14 .. note::
15
16     Be careful when using the ``raw`` filter inside expressions:
17
18     .. code-block:: jinja
19
20         {% autoescape %}
21             {% set hello = '<strong>Hello</strong>' %}
22             {% set hola = '<strong>Hola</strong>' %}
23
24             {{ false ? '<strong>Hola</strong>' : hello|raw }}
25             does not render the same as
26             {{ false ? hola : hello|raw }}
27             but renders the same as
28             {{ (false ? hola : hello)|raw }}
29         {% endautoescape %}
30
31     The first ternary statement is not escaped: ``hello`` is marked as being
32     safe and Twig does not escape static values (see
33     :doc:`escape<../tags/autoescape>`). In the second ternary statement, even
34     if ``hello`` is marked as safe, ``hola`` remains unsafe and so is the whole
35     expression. The third ternary statement is marked as safe and the result is
36     not escaped.