Skip to content
Newer
Older
100644 234 lines (206 sloc) 3.43 KB
3ebfa07 @abw Initial revision
authored Jun 25, 2000
1 #============================================================= -*-perl-*-
2 #
3 # t/tags.t
4 #
5 # Template script testing TAGS parse-time directive to switch the
6 # tokens that mark start and end of directive tags.
7 #
8 # Written by Andy Wardley <abw@kfs.org>
9 #
10 # Copyright (C) 1996-2000 Andy Wardley. All Rights Reserved.
11 # Copyright (C) 1998-2000 Canon Research Centre Europe Ltd.
12 #
13 # This is free software; you can redistribute it and/or modify it
14 # under the same terms as Perl itself.
15 #
16 # $Id$
17 #
18 #========================================================================
19
20 use strict;
fea9b8d @abw Updated various tests while fixing bugs
authored Aug 6, 2008
21 use lib qw( ./lib ../lib ./blib/lib ./blib/arch );
3ebfa07 @abw Initial revision
authored Jun 25, 2000
22 use Template::Test;
23 $^W = 1;
24
25 $Template::Test::DEBUG = 0;
26
27 my $params = {
28 'a' => 'alpha',
29 'b' => 'bravo',
30 'c' => 'charlie',
31 'd' => 'delta',
32 'e' => 'echo',
fea9b8d @abw Updated various tests while fixing bugs
authored Aug 6, 2008
33 tags => 'my tags',
34 flags => 'my flags',
3ebfa07 @abw Initial revision
authored Jun 25, 2000
35 };
36
6cbf6f6 @abw *** empty log message ***
authored Jul 7, 2000
37 my $tt = [
38 basic => Template->new(INTERPOLATE => 1),
39 htags => Template->new(TAG_STYLE => 'html'),
40 stags => Template->new(START_TAG => '\[\*', END_TAG => '\*\]'),
41 ];
3ebfa07 @abw Initial revision
authored Jun 25, 2000
42
6cbf6f6 @abw *** empty log message ***
authored Jul 7, 2000
43 test_expect(\*DATA, $tt, $params);
3ebfa07 @abw Initial revision
authored Jun 25, 2000
44
45 __DATA__
46 [%a%] [% a %] [% a %]
47 -- expect --
48 alpha alpha alpha
49
50 -- test --
51 Redefining tags
52 [% TAGS (+ +) %]
53 [% a %]
54 [% b %]
55 (+ c +)
56 -- expect --
57 Redefining tags
58
59 [% a %]
60 [% b %]
61 charlie
62
63 -- test --
64 [% a %]
65 [% TAGS (+ +) %]
66 [% a %]
67 %% b %%
68 (+ c +)
69 (+ TAGS <* *> +)
70 (+ d +)
71 <* e *>
72 -- expect --
73 alpha
74
75 [% a %]
76 %% b %%
77 charlie
78
79 (+ d +)
80 echo
81
82 -- test --
83 [% TAGS default -%]
84 [% a %]
85 %% b %%
86 (+ c +)
87 -- expect --
88 alpha
89 %% b %%
90 (+ c +)
91
92 -- test --
1303d12 @abw *** empty log message ***
authored Jul 4, 2000
93 # same as 'default'
94 [% TAGS template -%]
95 [% a %]
96 %% b %%
97 (+ c +)
98 -- expect --
99 alpha
100 %% b %%
101 (+ c +)
102
103 -- test --
3ebfa07 @abw Initial revision
authored Jun 25, 2000
104 [% TAGS metatext -%]
105 [% a %]
106 %% b %%
107 <* c *>
108 -- expect --
109 [% a %]
110 bravo
111 <* c *>
112
113 -- test --
1303d12 @abw *** empty log message ***
authored Jul 4, 2000
114 [% TAGS template1 -%]
3ebfa07 @abw Initial revision
authored Jun 25, 2000
115 [% a %]
116 %% b %%
117 (+ c +)
118 -- expect --
119 alpha
120 bravo
121 (+ c +)
122
123 -- test --
124 [% TAGS html -%]
125 [% a %]
126 %% b %%
127 <!-- c -->
128 -- expect --
129 [% a %]
130 %% b %%
131 charlie
132
133 -- test --
134 [% TAGS asp -%]
135 [% a %]
136 %% b %%
137 <!-- c -->
138 <% d %>
139 <? e ?>
140 -- expect --
141 [% a %]
142 %% b %%
143 <!-- c -->
144 delta
145 <? e ?>
146
147 -- test --
148 [% TAGS php -%]
149 [% a %]
150 %% b %%
151 <!-- c -->
152 <% d %>
153 <? e ?>
154 -- expect --
155 [% a %]
156 %% b %%
157 <!-- c -->
158 <% d %>
159 echo
160
6cbf6f6 @abw *** empty log message ***
authored Jul 7, 2000
161 #------------------------------------------------------------------------
162 # test processor with pre-defined TAG_STYLE
163 #------------------------------------------------------------------------
164 -- test --
165 -- use htags --
166 [% TAGS ignored -%]
167 [% a %]
168 <!-- c -->
169 more stuff
170 -- expect --
171 [% TAGS ignored -%]
172 [% a %]
173 charlie
174 more stuff
175
176 #------------------------------------------------------------------------
177 # test processor with pre-defined START_TAG and END_TAG
178 #------------------------------------------------------------------------
179 -- test --
180 -- use stags --
181 [% TAGS ignored -%]
182 <!-- also totally ignored and treated as text -->
183 [* a *]
184 blah [* b *] blah
185 -- expect --
186 [% TAGS ignored -%]
187 <!-- also totally ignored and treated as text -->
188 alpha
189 blah bravo blah
190
191
0b63aae @abw *** empty log message ***
authored Sep 8, 2000
192 #------------------------------------------------------------------------
193 # XML style tags
194 #------------------------------------------------------------------------
6cbf6f6 @abw *** empty log message ***
authored Jul 7, 2000
195
0b63aae @abw *** empty log message ***
authored Sep 8, 2000
196 -- test --
197 -- use basic --
198 [% TAGS <tt: > -%]
199 <tt:a=10->
200 a: <tt:a>
201 <tt:FOR a = [ 1, 3, 5, 7 ]->
202 <tt:a>
203 <tt:END->
204 -- expect --
205 a: 10
206 1
207 3
208 5
209 7
36ff03e @abw *** empty log message ***
authored Dec 15, 2000
210
211 -- test --
212 [% TAGS star -%]
213 [* a = 10 -*]
214 a is [* a *]
215 -- expect --
216 a is 10
fea9b8d @abw Updated various tests while fixing bugs
authored Aug 6, 2008
217
218 -- test --
219 [% tags; flags %]
220 [* a = 10 -*]
221 a is [* a *]
222 -- expect --
223 my tagsmy flags
224 [* a = 10 -*]
225 a is [* a *]
226
227 -- test --
228 flags: [% flags | html %]
229 tags: [% tags | html %]
230 -- expect --
231 flags: my flags
232 tags: my tags
233
Something went wrong with that request. Please try again.