]> Dogcows Code - chaz/p5-CGI-Ex/blob - t/7_template_02_view.t
CGI::Ex 2.11
[chaz/p5-CGI-Ex] / t / 7_template_02_view.t
1 # -*- Mode: Perl; -*-
2
3 =head1 NAME
4
5 7_template_02_view.t - Test the ability to handle views in CGI::Ex::Template
6
7 =cut
8
9 #============================================================= -*-perl-*-
10 #
11 # The tests used here where originally written by Andy Wardley
12 # They have been modified to work with this testing framework
13 # The following is the original Copyright notice included with
14 # the t/view.t document that these tests were taken from.
15 #
16 # Tests the 'View' plugin.
17 #
18 # Written by Andy Wardley <abw@kfs.org>
19 #
20 # Copyright (C) 2000 Andy Wardley. All Rights Reserved.
21 #
22 # This is free software; you can redistribute it and/or modify it
23 # under the same terms as Perl itself.
24 #
25 # Id: view.t 131 2001-06-14 13:20:12Z abw
26 #
27 #========================================================================
28
29 use vars qw($module $is_tt);
30 BEGIN {
31 $module = 'CGI::Ex::Template'; #real 0m0.885s #user 0m0.432s #sys 0m0.004s
32 # $module = 'Template'; #real 0m2.133s #user 0m1.108s #sys 0m0.024s
33 $is_tt = $module eq 'Template';
34 };
35
36 use strict;
37 use Test::More tests => ! $is_tt ? 53 : 53;
38 use Data::Dumper qw(Dumper);
39
40 use_ok($module);
41
42 my $skipped;
43 SKIP: {
44 if (! eval { require Template::View }) {
45 $skipped = 1;
46 skip("Template::View is not installed - skipping VIEW tests", 52);
47 }
48 };
49 exit if $skipped;
50
51
52 sub process_ok { # process the value and say if it was ok
53 my $str = shift;
54 my $test = shift;
55 my $vars = shift || {};
56 my $conf = local $vars->{'tt_config'} = $vars->{'tt_config'} || [];
57 my $obj = shift || $module->new(@$conf); # new object each time
58 my $out = '';
59 my $line = (caller)[2];
60 delete $vars->{'tt_config'};
61
62 $obj->process(\$str, $vars, \$out);
63 my $ok = ref($test) ? $out =~ $test : $out eq $test;
64 if ($ok) {
65 ok(1, "Line $line \"$str\" => \"$out\"");
66 return $obj;
67 } else {
68 ok(0, "Line $line \"$str\"");
69 warn "# Was:\n$out\n# Should've been:\n$test\n";
70 print $obj->error if $obj->can('error');
71 print Dumper $obj->parse_tree(\$str) if $obj->can('parse_tree');
72 exit;
73 }
74 }
75
76 ### This next section of code is verbatim from Andy's code
77 #------------------------------------------------------------------------
78 package Foo;
79
80 sub new {
81 my $class = shift;
82 bless { @_ }, $class;
83 }
84
85 sub present {
86 my $self = shift;
87 return '{ ' . join(', ', map { "$_ => $self->{ $_ }" }
88 sort keys %$self) . ' }';
89 }
90
91 sub reverse {
92 my $self = shift;
93 return '{ ' . join(', ', map { "$_ => $self->{ $_ }" }
94 reverse sort keys %$self) . ' }';
95 }
96
97 #------------------------------------------------------------------------
98 package Blessed::List;
99
100 sub as_list {
101 my $self = shift;
102 return @$self;
103 }
104
105 #------------------------------------------------------------------------
106 package main;
107
108 my $vars = {
109 foo => Foo->new( pi => 3.14, e => 2.718 ),
110 blessed_list => bless([ "Hello", "World" ], 'Blessed::List'),
111 };
112
113 ###----------------------------------------------------------------###
114 ### These are Andy's tests coded as Paul's process_oks
115
116 ### View plugin usage
117
118 process_ok("[% USE v = View -%]
119 [[% v.prefix %]]" => "[]", $vars);
120
121 process_ok("[% USE v = View( map => { default='any' } ) -%]
122 [[% v.map.default %]]" => "[any]", $vars);
123
124 process_ok("[% USE view( prefix=> 'foo/', suffix => '.tt2') -%]
125 [[% view.prefix %]bar[% view.suffix %]]
126 [[% view.template_name('baz') %]]" => "[foo/bar.tt2]
127 [foo/baz.tt2]", $vars);
128
129 process_ok("[% USE view( prefix=> 'foo/', suffix => '.tt2') -%]
130 [[% view.prefix %]bar[% view.suffix %]]
131 [[% view.template_name('baz') %]]" => "[foo/bar.tt2]
132 [foo/baz.tt2]", $vars);
133
134 process_ok("[% USE view -%]
135 [% view.print('Hello World') %]
136 [% BLOCK text %]TEXT: [% item %][% END -%]" => "TEXT: Hello World\n", $vars);
137
138 process_ok("[% USE view -%]
139 [% view.print( { foo => 'bar' } ) %]
140 [% BLOCK hash %]HASH: {
141 [% FOREACH key = item.keys.sort -%]
142 [% key %] => [% item.\$key %]
143 [%- END %]
144 }
145 [% END -%]" => "HASH: {
146 foo => bar
147 }\n\n", $vars);
148
149 process_ok("[% USE view -%]
150 [% view = view.clone( prefix => 'my_' ) -%]
151 [% view.view('hash', { bar => 'baz' }) %]
152 [% BLOCK my_hash %]HASH: {
153 [% FOREACH key = item.keys.sort -%]
154 [% key %] => [% item.\$key %]
155 [%- END %]
156 }
157 [% END -%]" => "HASH: {
158 bar => baz
159 }\n\n", $vars);
160
161 process_ok("[% USE view(prefix='my_') -%]
162 [% view.print( foo => 'wiz', bar => 'waz' ) %]
163 [% BLOCK my_hash %]KEYS: [% item.keys.sort.join(', ') %][% END %]
164
165 " => "KEYS: bar, foo\n\n\n", $vars);
166
167 process_ok("[% USE view -%]
168 [% view.print( view ) %]
169 [% BLOCK Template_View %]Printing a Template::View object[% END -%]" => "Printing a Template::View object\n", $vars);
170
171 process_ok("[% USE view(prefix='my_') -%]
172 [% view.print( view ) %]
173 [% view.print( view, prefix='your_' ) %]
174 [% BLOCK my_Template_View %]Printing my Template::View object[% END -%]
175 [% BLOCK your_Template_View %]Printing your Template::View object[% END -%]" => "Printing my Template::View object
176 Printing your Template::View object\n" , $vars);
177
178 process_ok("[% USE view(prefix='my_', notfound='any' ) -%]
179 [% view.print( view ) %]
180 [% view.print( view, prefix='your_' ) %]
181 [% BLOCK my_any %]Printing any of my objects[% END -%]
182 [% BLOCK your_any %]Printing any of your objects[% END -%]" => "Printing any of my objects
183 Printing any of your objects
184 ", $vars);
185
186 process_ok("[% USE view(prefix => 'my_', map => { default => 'catchall' } ) -%]
187 [% view.print( view ) %]
188 [% view.print( view, default='catchsome' ) %]
189 [% BLOCK my_catchall %]Catching all defaults[% END -%]
190 [% BLOCK my_catchsome %]Catching some defaults[% END -%]" => "Catching all defaults
191 Catching some defaults
192 ", $vars);
193
194 process_ok("[% USE view(prefix => 'my_', map => { default => 'catchnone' } ) -%]
195 [% view.default %]
196 [% view.default = 'catchall' -%]
197 [% view.default %]
198 [% view.print( view ) %]
199 [% view.print( view, default='catchsome' ) %]
200 [% BLOCK my_catchall %]Catching all defaults[% END -%]
201 [% BLOCK my_catchsome %]Catching some defaults[% END -%]" => "catchnone
202 catchall
203 Catching all defaults
204 Catching some defaults
205 ", $vars);
206
207 process_ok("[% USE view(prefix='my_', default='catchall' notfound='lost') -%]
208 [% view.print( view ) %]
209 [% BLOCK my_lost %]Something has been found[% END -%]" => "Something has been found
210 ", $vars);
211
212 process_ok("[% USE view -%]
213 [% TRY ;
214 view.print( view ) ;
215 CATCH view ;
216 \"[\$error.type] \$error.info\" ;
217 END
218 %]" => "[view] file error - Template_View: not found", $vars);
219
220 process_ok("[% USE view -%]
221 [% view.print( foo ) %]" => "{ e => 2.718, pi => 3.14 }", $vars);
222
223 process_ok("[% USE view -%]
224 [% view.print( foo, method => 'reverse' ) %]" => "{ pi => 3.14, e => 2.718 }", $vars);
225
226 process_ok("[% USE view(prefix='my_', include_naked=0, view_naked=1) -%]
227 [% BLOCK my_foo; \"Foo: \$item\"; END -%]
228 [[% view.view_foo(20) %]]
229 [[% view.foo(30) %]]" => "[Foo: 20]
230 [Foo: 30]", $vars);
231
232 process_ok("[% USE view(prefix='my_', include_naked=0, view_naked=0) -%]
233 [% BLOCK my_foo; \"Foo: \$item\"; END -%]
234 [[% view.view_foo(20) %]]
235 [% TRY ;
236 view.foo(30) ;
237 CATCH ;
238 error.info ;
239 END
240 %]" => "[Foo: 20]
241 no such view member: foo", $vars);
242
243 process_ok("[% USE view(map => { HASH => 'my_hash', ARRAY => 'your_list' }) -%]
244 [% BLOCK text %]TEXT: [% item %][% END -%]
245 [% BLOCK my_hash %]HASH: [% item.keys.sort.join(', ') %][% END -%]
246 [% BLOCK your_list %]LIST: [% item.join(', ') %][% END -%]
247 [% view.print(\"some text\") %]
248 [% view.print({ alpha => 'a', bravo => 'b' }) %]
249 [% view.print([ 'charlie', 'delta' ]) %]" => "TEXT: some text
250 HASH: alpha, bravo
251 LIST: charlie, delta", $vars);
252
253 process_ok("[% USE view(item => 'thing',
254 map => { HASH => 'my_hash', ARRAY => 'your_list' }) -%]
255 [% BLOCK text %]TEXT: [% thing %][% END -%]
256 [% BLOCK my_hash %]HASH: [% thing.keys.sort.join(', ') %][% END -%]
257 [% BLOCK your_list %]LIST: [% thing.join(', ') %][% END -%]
258 [% view.print(\"some text\") %]
259 [% view.print({ alpha => 'a', bravo => 'b' }) %]
260 [% view.print([ 'charlie', 'delta' ]) %]" => "TEXT: some text
261 HASH: alpha, bravo
262 LIST: charlie, delta", $vars);
263
264 process_ok("[% USE view -%]
265 [% view.print('Hello World') %]
266 [% view1 = view.clone( prefix='my_') -%]
267 [% view1.print('Hello World') %]
268 [% view2 = view1.clone( prefix='dud_', notfound='no_text' ) -%]
269 [% view2.print('Hello World') %]
270 [% BLOCK text %]TEXT: [% item %][% END -%]
271 [% BLOCK my_text %]MY TEXT: [% item %][% END -%]
272 [% BLOCK dud_no_text %]NO TEXT: [% item %][% END -%]" => "TEXT: Hello World
273 MY TEXT: Hello World
274 NO TEXT: Hello World
275 ", $vars);
276
277 process_ok("[% USE view( prefix = 'base_', default => 'any' ) -%]
278 [% view1 = view.clone( prefix => 'one_') -%]
279 [% view2 = view.clone( prefix => 'two_') -%]
280 [% view.default %] / [% view.map.default %]
281 [% view1.default = 'anyone' -%]
282 [% view1.default %] / [% view1.map.default %]
283 [% view2.map.default = 'anytwo' -%]
284 [% view2.default %] / [% view2.map.default %]
285 [% view.print(\"Hello World\") %] / [% view.print(blessed_list) %]
286 [% view1.print(\"Hello World\") %] / [% view1.print(blessed_list) %]
287 [% view2.print(\"Hello World\") %] / [% view2.print(blessed_list) %]
288 [% BLOCK base_text %]ANY TEXT: [% item %][% END -%]
289 [% BLOCK one_text %]ONE TEXT: [% item %][% END -%]
290 [% BLOCK two_text %]TWO TEXT: [% item %][% END -%]
291 [% BLOCK base_any %]BASE ANY: [% item.as_list.join(', ') %][% END -%]
292 [% BLOCK one_anyone %]ONE ANY: [% item.as_list.join(', ') %][% END -%]
293 [% BLOCK two_anytwo %]TWO ANY: [% item.as_list.join(', ') %][% END -%]" => "any / any
294 anyone / anyone
295 anytwo / anytwo
296 ANY TEXT: Hello World / BASE ANY: Hello, World
297 ONE TEXT: Hello World / ONE ANY: Hello, World
298 TWO TEXT: Hello World / TWO ANY: Hello, World
299 ", $vars);
300
301 process_ok("[% USE view( prefix => 'my_', item => 'thing' ) -%]
302 [% view.view('thingy', [ 'foo', 'bar'] ) %]
303 [% BLOCK my_thingy %]thingy: [ [% thing.join(', ') %] ][%END %]" => "thingy: [ foo, bar ]
304 ", $vars);
305
306 process_ok("[% USE view -%]
307 [% view.map.\${'Template::View'} = 'myview' -%]
308 [% view.print(view) %]
309 [% BLOCK myview %]MYVIEW[% END%]" => "MYVIEW
310 ", $vars);
311
312 process_ok("[% USE view -%]
313 [% view.include('greeting', msg => 'Hello World!') %]
314 [% BLOCK greeting %]msg: [% msg %][% END -%]" => "msg: Hello World!
315 ", $vars);
316
317 process_ok("[% USE view( prefix=\"my_\" )-%]
318 [% view.include('greeting', msg => 'Hello World!') %]
319 [% BLOCK my_greeting %]msg: [% msg %][% END -%]" => "msg: Hello World!
320 ", $vars);
321
322 process_ok("[% USE view( prefix=\"my_\" )-%]
323 [% view.include_greeting( msg => 'Hello World!') %]
324 [% BLOCK my_greeting %]msg: [% msg %][% END -%]" => "msg: Hello World!
325 ", $vars);
326
327 process_ok("[% USE view( prefix=\"my_\" )-%]
328 [% INCLUDE \$view.template('greeting')
329 msg = 'Hello World!' %]
330 [% BLOCK my_greeting %]msg: [% msg %][% END -%]" => "msg: Hello World!
331 ", $vars);
332
333 process_ok("[% USE view( title=\"My View\" )-%]
334 [% view.title %]" => "My View", $vars);
335
336 process_ok("[% USE view( title=\"My View\" )-%]
337 [% newview = view.clone( col = 'Chartreuse') -%]
338 [% newerview = newview.clone( title => 'New Title' ) -%]
339 [% view.title %]
340 [% newview.title %]
341 [% newview.col %]
342 [% newerview.title %]
343 [% newerview.col %]" => "My View
344 My View
345 Chartreuse
346 New Title
347 Chartreuse", $vars);
348
349 ###----------------------------------------------------------------###
350
351 ### VIEW directive usage
352
353 process_ok("[% VIEW fred prefix='blat_' %]
354 This is the view
355 [% END -%]
356 [% BLOCK blat_foo; 'This is blat_foo'; END -%]
357 [% fred.view_foo %]" => "This is blat_foo", $vars);
358
359 process_ok("[% VIEW fred %]
360 This is the view
361 [% view.prefix = 'blat_' %]
362 [% END -%]
363 [% BLOCK blat_foo; 'This is blat_foo'; END -%]
364 [% fred.view_foo %]" => "This is blat_foo", $vars);
365
366 process_ok("[% VIEW fred %]
367 This is the view
368 [% view.prefix = 'blat_' %]
369 [% view.thingy = 'bloop' %]
370 [% fred.name = 'Freddy' %]
371 [% END -%]
372 [% fred.prefix %]
373 [% fred.thingy %]
374 [% fred.name %]" => "blat_
375 bloop
376 Freddy", $vars);
377
378 process_ok("[% VIEW fred prefix='blat_'; view.name='Fred'; END -%]
379 [% fred.prefix %]
380 [% fred.name %]
381 [% TRY;
382 fred.prefix = 'nonblat_';
383 CATCH;
384 error;
385 END
386 %]
387 [% TRY;
388 fred.name = 'Derek';
389 CATCH;
390 error;
391 END
392 %]" => "blat_
393 Fred
394 view error - cannot update config item in sealed view: prefix
395 view error - cannot update item in sealed view: name", $vars);
396
397 process_ok("[% VIEW foo prefix='blat_' default=\"default\" notfound=\"notfound\"
398 title=\"fred\" age=23 height=1.82 %]
399 [% view.other = 'another' %]
400 [% END -%]
401 [% BLOCK blat_hash -%]
402 [% FOREACH key = item.keys.sort -%]
403 [% key %] => [% item.\$key %]
404 [% END -%]
405 [% END -%]
406 [% foo.print(foo.data) %]" => " age => 23
407 height => 1.82
408 other => another
409 title => fred
410 ", $vars);
411
412 process_ok("[% VIEW foo %]
413 [% BLOCK hello -%]
414 Hello World!
415 [% END %]
416 [% BLOCK goodbye -%]
417 Goodbye World!
418 [% END %]
419 [% END -%]
420 [% TRY; INCLUDE foo; CATCH; error; END %]
421 [% foo.include_hello %]" => "file error - foo: not found
422 Hello World!
423 ", $vars);
424
425 process_ok("[% title = \"Previous Title\" -%]
426 [% VIEW foo
427 include_naked = 1
428 title = title or 'Default Title'
429 copy = 'me, now'
430 -%]
431
432 [% view.bgcol = '#ffffff' -%]
433
434 [% BLOCK header -%]
435 Header: bgcol: [% view.bgcol %]
436 title: [% title %]
437 view.title: [% view.title %]
438 [%- END %]
439
440 [% BLOCK footer -%]
441 &copy; Copyright [% view.copy %]
442 [%- END %]
443
444 [% END -%]
445 [% title = 'New Title' -%]
446 [% foo.header %]
447 [% foo.header(bgcol='#dead' title=\"Title Parameter\") %]
448 [% foo.footer %]
449 [% foo.footer(copy=\"you, then\") %]
450 " => "Header: bgcol: #ffffff
451 title: New Title
452 view.title: Previous Title
453 Header: bgcol: #ffffff
454 title: Title Parameter
455 view.title: Previous Title
456 &copy; Copyright me, now
457 &copy; Copyright me, now
458 ", $vars);
459
460 process_ok("[% VIEW foo
461 title = 'My View'
462 author = 'Andy Wardley'
463 bgcol = bgcol or '#ffffff'
464 -%]
465 [% view.arg1 = 'argument #1' -%]
466 [% view.data.arg2 = 'argument #2' -%]
467 [% END -%]
468 [% foo.title %]
469 [% foo.author %]
470 [% foo.bgcol %]
471 [% foo.arg1 %]
472 [% foo.arg2 %]
473 [% bar = foo.clone( title='New View', arg1='New Arg1' ) %]cloned!
474 [% bar.title %]
475 [% bar.author %]
476 [% bar.bgcol %]
477 [% bar.arg1 %]
478 [% bar.arg2 %]
479 originals:
480 [% foo.title %]
481 [% foo.arg1 %]
482
483 " => " My View
484 Andy Wardley
485 #ffffff
486 argument #1
487 argument #2
488 cloned!
489 New View
490 Andy Wardley
491 #ffffff
492 New Arg1
493 argument #2
494 originals:
495 My View
496 argument #1
497
498 ", $vars);
499
500 process_ok("[% VIEW basic title = \"My Web Site\" %]
501 [% BLOCK header -%]
502 This is the basic header: [% title or view.title %]
503 [%- END -%]
504 [% END -%]
505
506 [%- VIEW fancy
507 title = \"<fancy>\$basic.title</fancy>\"
508 basic = basic
509 %]
510 [% BLOCK header ; view.basic.header(title = title or view.title) %]
511 Fancy new part of header
512 [%- END %]
513 [% END -%]
514 ===
515 [% basic.header %]
516 [% basic.header( title = \"New Title\" ) %]
517 ===
518 [% fancy.header %]
519 [% fancy.header( title = \"Fancy Title\" ) %]" => "===
520 This is the basic header: My Web Site
521 This is the basic header: New Title
522 ===
523 This is the basic header: <fancy>My Web Site</fancy>
524 Fancy new part of header
525 This is the basic header: Fancy Title
526 Fancy new part of header", $vars);
527
528 process_ok("[% VIEW baz notfound='lost' %]
529 [% BLOCK lost; 'lost, not found'; END %]
530 [% END -%]
531 [% baz.any %]" => "lost, not found", $vars);
532
533 process_ok("[% VIEW woz prefix='outer_' %]
534 [% BLOCK wiz; 'The inner wiz'; END %]
535 [% END -%]
536 [% BLOCK outer_waz; 'The outer waz'; END -%]
537 [% woz.wiz %]
538 [% woz.waz %]" => "The inner wiz
539 The outer waz", $vars);
540
541 process_ok("[% VIEW foo %]
542
543 [% BLOCK file -%]
544 File: [% item.name %]
545 [%- END -%]
546
547 [% BLOCK directory -%]
548 Dir: [% item.name %]
549 [%- END %]
550
551 [% END -%]
552 [% foo.view_file({ name => 'some_file' }) %]
553 [% foo.include_file(item => { name => 'some_file' }) %]
554 [% foo.view('directory', { name => 'some_dir' }) %]" => " File: some_file
555 File: some_file
556 Dir: some_dir", $vars);
557
558 process_ok("[% BLOCK parent -%]
559 This is the base block
560 [%- END -%]
561 [% VIEW super %]
562 [%- BLOCK parent -%]
563 [%- INCLUDE parent FILTER replace('base', 'super') -%]
564 [%- END -%]
565 [% END -%]
566 base: [% INCLUDE parent %]
567 super: [% super.parent %]" => "base: This is the base block
568 super: This is the super block", $vars);
569
570 process_ok("[% BLOCK foo -%]
571 public foo block
572 [%- END -%]
573 [% VIEW plain %]
574 [% BLOCK foo -%]
575 <plain>[% PROCESS foo %]</plain>
576 [%- END %]
577 [% END -%]
578 [% VIEW fancy %]
579 [% BLOCK foo -%]
580 [%- plain.foo | replace('plain', 'fancy') -%]
581 [%- END %]
582 [% END -%]
583 [% plain.foo %]
584 [% fancy.foo %]" => "<plain>public foo block</plain>
585 <fancy>public foo block</fancy>", $vars);
586
587 process_ok("[% VIEW foo %]
588 [% BLOCK Blessed_List -%]
589 This is a list: [% item.as_list.join(', ') %]
590 [% END -%]
591 [% END -%]
592 [% foo.print(blessed_list) %]" => "This is a list: Hello, World
593 ", $vars);
594
595 process_ok("[% VIEW my.foo value=33; END -%]
596 n: [% my.foo.value %]" => "n: 33", $vars);
597
598 process_ok("[% VIEW parent -%]
599 [% BLOCK one %]This is base one[% END %]
600 [% BLOCK two %]This is base two[% END %]
601 [% END -%]
602
603 [%- VIEW child1 base=parent %]
604 [% BLOCK one %]This is child1 one[% END %]
605 [% END -%]
606
607 [%- VIEW child2 base=parent %]
608 [% BLOCK two %]This is child2 two[% END %]
609 [% END -%]
610
611 [%- VIEW child3 base=child2 %]
612 [% BLOCK two %]This is child3 two[% END %]
613 [% END -%]
614
615 [%- FOREACH child = [ child1, child2, child3 ] -%]
616 one: [% child.one %]
617 [% END -%]
618 [% FOREACH child = [ child1, child2, child3 ] -%]
619 two: [% child.two %]
620 [% END %]
621 " => "one: This is child1 one
622 one: This is base one
623 one: This is base one
624 two: This is base two
625 two: This is child2 two
626 two: This is child3 two
627
628 ", $vars);
629
630 process_ok("[% VIEW my.view.default
631 prefix = 'view/default/'
632 value = 3.14;
633 END
634 -%]
635 value: [% my.view.default.value %]" => "value: 3.14", $vars);
636
637 process_ok("[% VIEW my.view.default
638 prefix = 'view/default/'
639 value = 3.14;
640 END;
641 VIEW my.view.one
642 base = my.view.default
643 prefix = 'view/one/';
644 END;
645 VIEW my.view.two
646 base = my.view.default
647 value = 2.718;
648 END;
649 -%]
650 [% BLOCK view/default/foo %]Default foo[% END -%]
651 [% BLOCK view/one/foo %]One foo[% END -%]
652 0: [% my.view.default.foo %]
653 1: [% my.view.one.foo %]
654 2: [% my.view.two.foo %]
655 0: [% my.view.default.value %]
656 1: [% my.view.one.value %]
657 2: [% my.view.two.value %]" => "0: Default foo
658 1: One foo
659 2: Default foo
660 0: 3.14
661 1: 3.14
662 2: 2.718", $vars);
663
664 process_ok("[% VIEW foo number = 10 sealed = 0; END -%]
665 a: [% foo.number %]
666 b: [% foo.number = 20 %]
667 c: [% foo.number %]
668 d: [% foo.number(30) %]
669 e: [% foo.number %]" => "a: 10
670 b:
671 c: 20
672 d: 30
673 e: 30", $vars);
674
675 process_ok("[% VIEW foo number = 10 silent = 1; END -%]
676 a: [% foo.number %]
677 b: [% foo.number = 20 %]
678 c: [% foo.number %]
679 d: [% foo.number(30) %]
680 e: [% foo.number %]" => "a: 10
681 b:
682 c: 10
683 d: 10
684 e: 10", $vars);
This page took 0.057721 seconds and 4 git commands to generate.