2 "autoescape" tag applies escaping after calling filters
4 {% autoescape 'html' %}
6 (escape_and_nl2br is an escaper filter)
8 1. Don't escape escaper filter output
9 ( var is escaped by |escape_and_nl2br, line-breaks are added,
10 the output is not escaped )
11 {{ var|escape_and_nl2br }}
13 2. Don't escape escaper filter output
14 ( var is escaped by |escape_and_nl2br, line-breaks are added,
15 the output is not escaped, |raw is redundant )
16 {{ var|escape_and_nl2br|raw }}
19 ( var is escaped by |escape_and_nl2br, line-breaks are added,
20 the output is explicitly escaped by |escape )
21 {{ var|escape_and_nl2br|escape }}
23 4. Escape non-escaper filter output
24 ( var is upper-cased by |upper,
25 the output is auto-escaped )
28 5. Escape if last filter is not an escaper
29 ( var is escaped by |escape_and_nl2br, line-breaks are added,
30 the output is upper-cased by |upper,
31 the output is auto-escaped as |upper is not an escaper )
32 {{ var|escape_and_nl2br|upper }}
34 6. Don't escape escaper filter output
35 ( var is upper cased by upper,
36 the output is escaped by |escape_and_nl2br, line-breaks are added,
37 the output is not escaped as |escape_and_nl2br is an escaper )
38 {{ var|upper|escape_and_nl2br }}
40 7. Escape if last filter is not an escaper
41 ( the output of |format is "<b>" ~ var ~ "</b>",
42 the output is auto-escaped )
43 {{ "<b>%s</b>"|format(var) }}
45 8. Escape if last filter is not an escaper
46 ( the output of |format is "<b>" ~ var ~ "</b>",
48 the output is auto-escaped )
49 {{ "<b>%s</b>"|raw|format(var) }}
51 9. Don't escape escaper filter output
52 ( the output of |format is "<b>" ~ var ~ "</b>",
53 the output is not escaped due to |raw filter at the end )
54 {{ "<b>%s</b>"|format(var)|raw }}
56 10. Don't escape escaper filter output
57 ( the output of |format is "<b>" ~ var ~ "</b>",
58 the output is not escaped due to |raw filter at the end,
59 the |raw filter on var is redundant )
60 {{ "<b>%s</b>"|format(var|raw)|raw }}
64 return array('var' => "<Fabien>\nTwig")
67 (escape_and_nl2br is an escaper filter)
69 1. Don't escape escaper filter output
70 ( var is escaped by |escape_and_nl2br, line-breaks are added,
71 the output is not escaped )
75 2. Don't escape escaper filter output
76 ( var is escaped by |escape_and_nl2br, line-breaks are added,
77 the output is not escaped, |raw is redundant )
82 ( var is escaped by |escape_and_nl2br, line-breaks are added,
83 the output is explicitly escaped by |escape )
84 &lt;Fabien&gt;<br />
87 4. Escape non-escaper filter output
88 ( var is upper-cased by |upper,
89 the output is auto-escaped )
93 5. Escape if last filter is not an escaper
94 ( var is escaped by |escape_and_nl2br, line-breaks are added,
95 the output is upper-cased by |upper,
96 the output is auto-escaped as |upper is not an escaper )
97 &LT;FABIEN&GT;<BR />
100 6. Don't escape escaper filter output
101 ( var is upper cased by upper,
102 the output is escaped by |escape_and_nl2br, line-breaks are added,
103 the output is not escaped as |escape_and_nl2br is an escaper )
107 7. Escape if last filter is not an escaper
108 ( the output of |format is "<b>" ~ var ~ "</b>",
109 the output is auto-escaped )
110 <b><Fabien>
113 8. Escape if last filter is not an escaper
114 ( the output of |format is "<b>" ~ var ~ "</b>",
116 the output is auto-escaped )
117 <b><Fabien>
120 9. Don't escape escaper filter output
121 ( the output of |format is "<b>" ~ var ~ "</b>",
122 the output is not escaped due to |raw filter at the end )
126 10. Don't escape escaper filter output
127 ( the output of |format is "<b>" ~ var ~ "</b>",
128 the output is not escaped due to |raw filter at the end,
129 the |raw filter on var is redundant )