Commit | Line | Data |
540289da |
1 | #!/usr/local/bin/perl |
2 | |
3 | use strict ; |
4 | use warnings ; |
5 | |
6 | use Template::Simple ; |
7 | |
8 | my $tmpl = Template::Simple->new() ; |
9 | |
10 | $tmpl->add_templates( { ddd => <<DDD } ) ; |
11 | text1 |
12 | [%START nest%] |
13 | BAR is [%bar%] |
14 | [%END nest%] |
15 | DDD |
16 | |
17 | my %data = ( |
18 | ddd => [ |
19 | { |
20 | nest => { |
21 | bar => 'xxx', |
22 | }, |
23 | }, |
24 | { |
25 | nest => { |
26 | bar => 'yyy', |
27 | }, |
28 | }, |
29 | { |
30 | nest => { |
31 | bar => 'zzz', |
32 | }, |
33 | }, |
34 | ], |
35 | ) ; |
36 | |
37 | $tmpl->compile('foo') ; |
38 | #$tmpl->compile('fooz') ; |
39 | |
40 | #my $rendered = $tmpl->render('foo', { foo => 2, bar => 'xxx' } ) ; |
41 | |
42 | #print "REND [$$rendered]\n" ; |
43 | |
44 | $tmpl->compile('ddd') ; |
45 | my $rendered = $tmpl->render( 'ddd', $data{ddd} ) ; |
46 | |
47 | print "REND [$$rendered]\n" ; |
48 | |
49 | print $tmpl->get_source( 'ddd' ) ; |
50 | |
51 | exit ; |