Yaffs site version 1.1
[yaffs-website] / vendor / twig / twig / test / Twig / Tests / Fixtures / tags / autoescape / with_filters.test
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
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 }}
12
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 }}
17
18 3. 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
23 4. Escape non-escaper filter output
24 ( var is upper-cased by |upper,
25   the output is auto-escaped )
26 {{ var|upper }}
27
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 }}
33
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 }}
39
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) }}
44
45 8. 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
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 }}
55
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 }}
61
62 {% endautoescape %}
63 --DATA--
64 return array('var' => "<Fabien>\nTwig")
65 --EXPECT--
66
67 (escape_and_nl2br is an escaper filter)
68
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 )
72 &lt;Fabien&gt;<br />
73 Twig
74
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 )
78 &lt;Fabien&gt;<br />
79 Twig
80
81 3. Explicit escape
82 ( var is escaped by |escape_and_nl2br, line-breaks are added,
83   the output is explicitly escaped by |escape )
84 &amp;lt;Fabien&amp;gt;&lt;br /&gt;
85 Twig
86
87 4. Escape non-escaper filter output
88 ( var is upper-cased by |upper,
89   the output is auto-escaped )
90 &lt;FABIEN&gt;
91 TWIG
92
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 &amp;LT;FABIEN&amp;GT;&lt;BR /&gt;
98 TWIG
99
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 )
104 &lt;FABIEN&gt;<br />
105 TWIG
106
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 &lt;b&gt;&lt;Fabien&gt;
111 Twig&lt;/b&gt;
112
113 8. 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 &lt;b&gt;&lt;Fabien&gt;
118 Twig&lt;/b&gt;
119
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 )
123 <b><Fabien>
124 Twig</b>
125
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 )
130 <b><Fabien>
131 Twig</b>