--TEST-- "autoescape" tag applies escaping after calling filters --TEMPLATE-- {% autoescape 'html' %} (escape_and_nl2br is an escaper filter) 1. Don't escape escaper filter output ( var is escaped by |escape_and_nl2br, line-breaks are added, the output is not escaped ) {{ var|escape_and_nl2br }} 2. Don't escape escaper filter output ( var is escaped by |escape_and_nl2br, line-breaks are added, the output is not escaped, |raw is redundant ) {{ var|escape_and_nl2br|raw }} 3. Explicit escape ( var is escaped by |escape_and_nl2br, line-breaks are added, the output is explicitly escaped by |escape ) {{ var|escape_and_nl2br|escape }} 4. Escape non-escaper filter output ( var is upper-cased by |upper, the output is auto-escaped ) {{ var|upper }} 5. Escape if last filter is not an escaper ( var is escaped by |escape_and_nl2br, line-breaks are added, the output is upper-cased by |upper, the output is auto-escaped as |upper is not an escaper ) {{ var|escape_and_nl2br|upper }} 6. Don't escape escaper filter output ( var is upper cased by upper, the output is escaped by |escape_and_nl2br, line-breaks are added, the output is not escaped as |escape_and_nl2br is an escaper ) {{ var|upper|escape_and_nl2br }} 7. Escape if last filter is not an escaper ( the output of |format is "" ~ var ~ "", the output is auto-escaped ) {{ "%s"|format(var) }} 8. Escape if last filter is not an escaper ( the output of |format is "" ~ var ~ "", |raw is redundant, the output is auto-escaped ) {{ "%s"|raw|format(var) }} 9. Don't escape escaper filter output ( the output of |format is "" ~ var ~ "", the output is not escaped due to |raw filter at the end ) {{ "%s"|format(var)|raw }} 10. Don't escape escaper filter output ( the output of |format is "" ~ var ~ "", the output is not escaped due to |raw filter at the end, the |raw filter on var is redundant ) {{ "%s"|format(var|raw)|raw }} {% endautoescape %} --DATA-- return ['var' => "\nTwig"] --EXPECT-- (escape_and_nl2br is an escaper filter) 1. Don't escape escaper filter output ( var is escaped by |escape_and_nl2br, line-breaks are added, the output is not escaped ) <Fabien>
Twig 2. Don't escape escaper filter output ( var is escaped by |escape_and_nl2br, line-breaks are added, the output is not escaped, |raw is redundant ) <Fabien>
Twig 3. Explicit escape ( var is escaped by |escape_and_nl2br, line-breaks are added, the output is explicitly escaped by |escape ) &lt;Fabien&gt;<br /> Twig 4. Escape non-escaper filter output ( var is upper-cased by |upper, the output is auto-escaped ) <FABIEN> TWIG 5. Escape if last filter is not an escaper ( var is escaped by |escape_and_nl2br, line-breaks are added, the output is upper-cased by |upper, the output is auto-escaped as |upper is not an escaper ) &LT;FABIEN&GT;<BR /> TWIG 6. Don't escape escaper filter output ( var is upper cased by upper, the output is escaped by |escape_and_nl2br, line-breaks are added, the output is not escaped as |escape_and_nl2br is an escaper ) <FABIEN>
TWIG 7. Escape if last filter is not an escaper ( the output of |format is "" ~ var ~ "", the output is auto-escaped ) <b><Fabien> Twig</b> 8. Escape if last filter is not an escaper ( the output of |format is "" ~ var ~ "", |raw is redundant, the output is auto-escaped ) <b><Fabien> Twig</b> 9. Don't escape escaper filter output ( the output of |format is "" ~ var ~ "", the output is not escaped due to |raw filter at the end ) Twig 10. Don't escape escaper filter output ( the output of |format is "" ~ var ~ "", the output is not escaped due to |raw filter at the end, the |raw filter on var is redundant ) Twig