aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/with_filters.test
blob: 7821a9aafd7e06a11dcb84879a01ac16e7ac94fc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
--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 "<b>" ~ var ~ "</b>",
  the output is auto-escaped )
{{ "<b>%s</b>"|format(var) }}

8. Escape if last filter is not an escaper
( the output of |format is "<b>" ~ var ~ "</b>",
  |raw is redundant,
  the output is auto-escaped )
{{ "<b>%s</b>"|raw|format(var) }}

9. Don't escape escaper filter output
( the output of |format is "<b>" ~ var ~ "</b>",
  the output is not escaped due to |raw filter at the end )
{{ "<b>%s</b>"|format(var)|raw }}

10. Don't escape escaper filter output
( the output of |format is "<b>" ~ var ~ "</b>",
  the output is not escaped due to |raw filter at the end,
  the |raw filter on var is redundant )
{{ "<b>%s</b>"|format(var|raw)|raw }}

{% endautoescape %}
--DATA--
return array('var' => "<Fabien>\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 )
&lt;Fabien&gt;<br />
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 )
&lt;Fabien&gt;<br />
Twig

3. Explicit escape
( var is escaped by |escape_and_nl2br, line-breaks are added,
  the output is explicitly escaped by |escape )
&amp;lt;Fabien&amp;gt;&lt;br /&gt;
Twig

4. Escape non-escaper filter output
( var is upper-cased by |upper,
  the output is auto-escaped )
&lt;FABIEN&gt;
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 )
&amp;LT;FABIEN&amp;GT;&lt;BR /&gt;
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 )
&lt;FABIEN&gt;<br />
TWIG

7. Escape if last filter is not an escaper
( the output of |format is "<b>" ~ var ~ "</b>",
  the output is auto-escaped )
&lt;b&gt;&lt;Fabien&gt;
Twig&lt;/b&gt;

8. Escape if last filter is not an escaper
( the output of |format is "<b>" ~ var ~ "</b>",
  |raw is redundant,
  the output is auto-escaped )
&lt;b&gt;&lt;Fabien&gt;
Twig&lt;/b&gt;

9. Don't escape escaper filter output
( the output of |format is "<b>" ~ var ~ "</b>",
  the output is not escaped due to |raw filter at the end )
<b><Fabien>
Twig</b>

10. Don't escape escaper filter output
( the output of |format is "<b>" ~ var ~ "</b>",
  the output is not escaped due to |raw filter at the end,
  the |raw filter on var is redundant )
<b><Fabien>
Twig</b>