Leser: 2
|< 1 2 >| | 13 Einträge, 2 Seiten |
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
use strict;
use warnings;
use HTML::Template;
my $template = HTML::Template->new(filename => './test.tmpl');
my @daten = (
{
'var11' => 'val11',
'var12' => [
{
'var21' => 'val21',
'var22' => [
{
'var31' => 'val31',
'var32' => 'val32'
}
]
}
]
}
);
$template->param(LOOP => \@daten);
print $template->output();
1
2
3
4
5
6
7
8
9
10
<TMPL_LOOP NAME="LOOP">
<TMPL_VAR NAME="VAR11">
<TMPL_LOOP NAME="VAR12">
<TMPL_VAR NAME="VAR21">
<TMPL_LOOP NAME="VAR22">
<TMPL_VAR NAME="VAR31">
<TMPL_VAR NAME="VAR32">
</TMPL_LOOP>
</TMPL_LOOP>
</TMPL_LOOP>
1
2
3
4
5
6
7
<ul>
<TMPL_LOOP NAME="catLoop">
<li><TMPL_VAR NAME="catName">
<TMPL_INCLUDE NAME="cat-tree.inc">
</li>
</TMPL_LOOP>
</ul>
$template->param(meineListe => $myList)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$var = [
{
'cat_id' => 1,
'cat_name' => 'Foo',
'cat_sub' => {
'cat_id' => 2,
'cat_name' => 'Bar',
'cat_sub' => []
}
},
{
'cat_id' => 3,
'cat_name' => 'Buz',
'cat_sub' => []
}
]
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
$var = [
{
'cat_id' => 1,
'cat_name' => 'Foo',
'inc' => undef,
'dec' => undef,
},
{
'cat_id' => undef,
'cat_name' => undef,
'inc' => 1,
'dec' => undef,
},
{
'cat_id' => 2,
'cat_name' => 'Bar',
'inc' => undef,
'dec' => undef,
},
{
'cat_id' => undef,
'cat_name' => undef,
'inc' => undef,
'dec' => 1,
},
{
'cat_id' => 3,
'cat_name' => 'Buz',
'inc' => undef,
'dec' => undef,
},
]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<ul>
<TMPL_LOOP NAME="catLoop">
<TMPL_IF NAME="inc">
<ul>
</TMPL_IF>
<TMPL_IF NAME="cat_id">
<li><input type="checkbox" name="cat" id="c<TMPL_VAR NAME="cat_id">" value="<TMPL_VAR NAME="cat_id">" />
<label for="c<TMPL_VAR NAME="cat_id">"><TMPL_VAR NAME="cat_name"></label>
</TMPL_IF>
<TMPL_IF NAME="dec">
</ul></li>
<TMPL_ELSE>
</li>
</TMPL_IF>
</TMPL_LOOP>
</ul>
|< 1 2 >| | 13 Einträge, 2 Seiten |