4 Whether automatic escaping is enabled or not, you can mark a section of a
5 template to be escaped or not by using the ``autoescape`` tag:
9 {# The following syntax works as of Twig 1.8 -- see the note below for previous versions #}
12 Everything will be automatically escaped in this block
13 using the HTML strategy
16 {% autoescape 'html' %}
17 Everything will be automatically escaped in this block
18 using the HTML strategy
22 Everything will be automatically escaped in this block
23 using the js escaping strategy
26 {% autoescape false %}
27 Everything will be outputted as is in this block
32 Before Twig 1.8, the syntax was different:
37 Everything will be automatically escaped in this block
38 using the HTML strategy
41 {% autoescape false %}
42 Everything will be outputted as is in this block
45 {% autoescape true js %}
46 Everything will be automatically escaped in this block
47 using the js escaping strategy
50 When automatic escaping is enabled everything is escaped by default except for
51 values explicitly marked as safe. Those can be marked in the template by using
52 the :doc:`raw<../filters/raw>` filter:
60 Functions returning template data (like :doc:`macros<macro>` and
61 :doc:`parent<../functions/parent>`) always return safe markup.
65 Twig is smart enough to not escape an already escaped value by the
66 :doc:`escape<../filters/escape>` filter.
70 The chapter :doc:`Twig for Developers<../api>` gives more information
71 about when and how automatic escaping is applied.