1--TEST-- 2"autoescape" tag applies escaping after calling filters 3--TEMPLATE-- 4{% autoescape 'html' %} 5 6(escape_and_nl2br is an escaper filter) 7 81. 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 }} 12 132. 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 }} 17 183. Explicit escape 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 }} 22 234. Escape non-escaper filter output 24( var is upper-cased by |upper, 25 the output is auto-escaped ) 26{{ var|upper }} 27 285. 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 }} 33 346. 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 }} 39 407. 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) }} 44 458. Escape if last filter is not an escaper 46( the output of |format is "<b>" ~ var ~ "</b>", 47 |raw is redundant, 48 the output is auto-escaped ) 49{{ "<b>%s</b>"|raw|format(var) }} 50 519. 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 }} 55 5610. 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 }} 61 62{% endautoescape %} 63--DATA-- 64return ['var' => "<Fabien>\nTwig"] 65--EXPECT-- 66 67(escape_and_nl2br is an escaper filter) 68 691. Don't escape escaper filter output 70( var is escaped by |escape_and_nl2br, line-breaks are added, 71 the output is not escaped ) 72<Fabien><br /> 73Twig 74 752. 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 ) 78<Fabien><br /> 79Twig 80 813. Explicit escape 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 /> 85Twig 86 874. Escape non-escaper filter output 88( var is upper-cased by |upper, 89 the output is auto-escaped ) 90<FABIEN> 91TWIG 92 935. 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 /> 98TWIG 99 1006. 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 ) 104<FABIEN><br /> 105TWIG 106 1077. 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> 111Twig</b> 112 1138. Escape if last filter is not an escaper 114( the output of |format is "<b>" ~ var ~ "</b>", 115 |raw is redundant, 116 the output is auto-escaped ) 117<b><Fabien> 118Twig</b> 119 1209. 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 ) 123<b><Fabien> 124Twig</b> 125 12610. 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 ) 130<b><Fabien> 131Twig</b> 132