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