Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 379 lines (320 sloc) 4.871 kb
850d474a »
2000-07-05 *** empty log message ***
1 #============================================================= -*-perl-*-
2 #
3 # t/directive.t
4 #
5 # Test basic directive layout and processing options.
6 #
7 # Written by Andy Wardley <abw@kfs.org>
8 #
9 # Copyright (C) 1996-2000 Andy Wardley. All Rights Reserved.
10 # Copyright (C) 1998-2000 Canon Research Centre Europe Ltd.
11 #
12 # This is free software; you can redistribute it and/or modify it
13 # under the same terms as Perl itself.
14 #
15 # $Id$
16 #
17 #========================================================================
18
19 use strict;
20 use lib qw( ./lib ../lib );
21 use Template::Test;
22 $^W = 1;
23
70214227 »
2000-07-06 *** empty log message ***
24 my $ttobjs = [
25 tt => Template->new(),
26 pre => Template->new( PRE_CHOMP => 1 ),
27 post => Template->new( POST_CHOMP => 1 ),
28 trim => Template->new( INCLUDE_PATH => -d 't' ? 't/test/lib' : 'test/lib',
29 TRIM => 1 ),
30 ];
850d474a »
2000-07-05 *** empty log message ***
31
70214227 »
2000-07-06 *** empty log message ***
32 test_expect(\*DATA, $ttobjs, callsign);
850d474a »
2000-07-05 *** empty log message ***
33
34 __DATA__
35 #------------------------------------------------------------------------
6cbf6f6c »
2000-07-07 *** empty log message ***
36 # basic directives
37 #------------------------------------------------------------------------
38 -- test --
39 [% a %]
40 [%a%]
41 -- expect --
42 alpha
43 alpha
44
45 -- test --
46 pre [% a %]
47 pre[% a %]
48 -- expect --
49 pre alpha
50 prealpha
51
52 -- test --
53 [% a %] post
54 [% a %]post
55 -- expect --
56 alpha post
57 alphapost
58
59 -- test --
60 pre [% a %] post
61 pre[% a %]post
62 -- expect --
63 pre alpha post
64 prealphapost
65
66 -- test --
67 [% a %][%b%][% c %]
68 -- expect --
69 alphabravocharlie
70
71 -- test --
72 [%
73 a %][%b
74 %][%
75 c
76 %][%
77 d
78 %]
79 -- expect --
80 alphabravocharliedelta
81
82 #------------------------------------------------------------------------
850d474a »
2000-07-05 *** empty log message ***
83 # comments
84 #------------------------------------------------------------------------
85 -- test --
86 [%# this is a comment which should
87 be ignored in totality
88 %]hello world
89 -- expect --
90 hello world
91
92 -- test --
93 [% # this is a one-line comment
94 a
95 %]
96 -- expect --
97 alpha
98
99 -- test --
100 [% # this is a two-line comment
101 a =
102 # here's the next line
103 b
104 -%]
105 [% a %]
106 -- expect --
107 bravo
108
109 -- test --
110 [% a = c # this is a comment on the end of the line
111 b = d # so is this
112 -%]
113 a: [% a %]
114 b: [% b %]
115 -- expect --
116 a: charlie
117 b: delta
118
119 #------------------------------------------------------------------------
120 # manual chomping
121 #------------------------------------------------------------------------
122
123 -- test --
124 [% a %]
125 [% b %]
126 -- expect --
127 alpha
128 bravo
129
130 -- test --
131 [% a -%]
132 [% b %]
133 -- expect --
134 alphabravo
135
136 -- test --
137 [% a -%]
138 [% b %]
139 -- expect --
140 alpha bravo
141
142 -- test --
143 [% a %]
144 [%- b %]
145 -- expect --
146 alphabravo
147
148 -- test --
149 [% a %]
150 [%- b %]
151 -- expect --
152 alphabravo
153
154 -- test --
155 start
156 [% a %]
157 [% b %]
158 end
159 -- expect --
160 start
161 alpha
162 bravo
163 end
164
165 -- test --
166 start
167 [%- a %]
168 [% b -%]
169 end
170 -- expect --
171 startalpha
172 bravoend
173
174 -- test --
175 start
176 [%- a -%]
177 [% b -%]
178 end
179 -- expect --
180 startalphabravoend
181
182 -- test --
183 start
184 [%- a %]
185 [%- b -%]
186 end
187 -- expect --
188 startalphabravoend
189
190 #------------------------------------------------------------------------
191 # PRE_CHOMP enabled
192 #------------------------------------------------------------------------
193
194 -- test --
195 -- use pre --
196 start
197 [% a %]
198 mid
199 [% b %]
200 end
201 -- expect --
202 startalpha
203 midbravo
204 end
205
206 -- test --
207 start
208 [% a %]
209 mid
210 [% b %]
211 end
212 -- expect --
213 startalpha
214 midbravo
215 end
216
217 -- test --
218 start
219 [%+ a %]
220 mid
221 [% b %]
222 end
223 -- expect --
224 start
225 alpha
226 midbravo
227 end
228
229 -- test --
230 start
231 [%+ a %]
232 mid
233 [% b %]
234 end
235 -- expect --
236 start
237 alpha
238 midbravo
239 end
240
241 -- test --
242 start
243 [%- a %]
244 mid
245 [%- b %]
246 end
247 -- expect --
248 startalpha
249 midbravo
250 end
251
252 #------------------------------------------------------------------------
253 # POST_CHOMP enabled
254 #------------------------------------------------------------------------
255
256 -- test --
257 -- use post --
258 start
259 [% a %]
260 mid
261 [% b %]
262 end
263 -- expect --
264 start
265 alphamid
266 bravoend
267
268 -- test --
269 start
270 [% a %]
271 mid
272 [% b %]
273 end
274 -- expect --
275 start
276 alphamid
277 bravoend
278
279 -- test --
280 start
281 [% a +%]
282 mid
283 [% b %]
284 end
285 -- expect --
286 start
287 alpha
288 mid
289 bravoend
290
291 -- test --
292 start
293 [% a +%]
294 [% b +%]
295 end
296 -- expect --
297 start
298 alpha
299 bravo
300 end
301
302 -- test --
303 start
304 [% a -%]
305 mid
306 [% b -%]
307 end
308 -- expect --
309 start
310 alphamid
311 bravoend
312
313
70214227 »
2000-07-06 *** empty log message ***
314 #------------------------------------------------------------------------
315 # TRIM enabled
316 #------------------------------------------------------------------------
317 -- test --
318 -- use trim --
319
320 [% INCLUDE trimme %]
321
322
323 -- expect --
324 I am a template element file which will get TRIMmed
325
326
327 -- test --
328 [% BLOCK foo %]
329
330 this is block foo
331
332 [% END -%]
333
334 [% BLOCK bar %]
335
336 this is block bar
337
338 [% END %]
339
340 [% INCLUDE foo %]
341 [% INCLUDE bar %]
342 end
343 -- expect --
344 this is block foo
345 this is block bar
346 end
347
a3148193 »
2000-12-01 v2.00
348
349 -- test --
350 <foo>[% PROCESS foo %]</foo>
351 <bar>[% PROCESS bar %]</bar>
352 [% BLOCK foo %]
353
354 this is block foo
355
356 [% END -%]
357 [% BLOCK bar %]
358
359 this is block bar
360
361 [% END -%]
362 end
363 -- expect --
364 <foo>this is block foo</foo>
365 <bar>this is block bar</bar>
366 end
367
368
6cbf6f6c »
2000-07-07 *** empty log message ***
369 -- test --
e1ad1609 »
2000-07-07 *** empty log message ***
370 [% r; r = s; "-"; r %].
371 -- expect --
372 romeo-sierra.
373
374 -- test --
375 [% IF a; b; ELSIF c; d; ELSE; s; END %]
376 -- expect --
377 bravo
378
Something went wrong with that request. Please try again.