Thread HTML:Template zum zweiten. (10 answers)
Opened by jan10001 at 2003-08-26 19:12

kabel
 2003-08-26 22:07
#80345 #80345
User since
2003-08-04
704 Artikel
BenutzerIn
[default_avatar]
da hat wohl jemand die doku falsch verstanden.

Quote
<TMPL_IF> </TMPL_IF> blocks can include any valid HTML::Template construct - VARs and LOOPs and other IF/ELSE blocks. Note, however, that intersecting a <TMPL_IF> and a <TMPL_LOOP> is invalid.

Not going to work:
<TMPL_IF BOOL>
<TMPL_LOOP SOME_LOOP>
</TMPL_IF>
</TMPL_LOOP>


Code: (dl )
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
kabel@linux:~/progs/perl> cat html_template.pl
use strict;
use HTML::Template;
my $t_text = q~
<TMPL_IF NAME="BOOL">
<TMPL_LOOP NAME=PERSONS>
name: <TMPL_VAR NAME=name>
age : <TMPL_VAR NAME=age>
</TMPL_LOOP>
</TMPL_IF>
~;
my $t = HTML::Template->new (scalarref => \$t_text);
$t->param (BOOL => 1);
$t->param (PERSONS => [
{ name => "kabel", age => "22" },
{ name => "chef", age => "22" },
]);

print STDOUT $t->output ();

kabel@linux:~/progs/perl> perl -w html_template.pl



name: kabel
age : 22

name: chef
age : 22


kabel@linux:~/progs/perl>
-- stefan

View full thread HTML:Template zum zweiten.