|< 1 2 >| | 11 Einträge, 2 Seiten |
Quote\n\nmy $template = HTML::Template->new(filename => 'test.tmpl' );
HTML::Template->new() : found <//TMPL_IF> with no matching <TMPL_IF> at bundesland.tmpl : line 63. at /usr/share/perl5/HTML/Template.pm line 2117.
1
2
3
4
5
<TMPL_IF NAME="BOOL">
<TMPL_LOOP NAME=GESAMT>
<a href="<TMPL_VAR NAME=LINK>" target="_top"><TMPL_VAR NAME=ZIEL></a><br>
</TMPL>
</TMPL_IF>
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>
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>
1
2
3
4
5
<TMPL_IF NAME="BOOL">
<TMPL_LOOP NAME=GESAMT>
<a href="<TMPL_VAR NAME=LINK>" target="_top"><TMPL_VAR NAME=ZIEL></a><br>
</TMPL>
</TMPL_IF>
|< 1 2 >| | 11 Einträge, 2 Seiten |