in reply to Re^2: HTML::Template __even__
in thread HTML::Template __even__
Then in your template:my $rows; my $class = 'odd'; for my $name ( qw(Odd1 Even1 Odd2 Even2) ) { my $hash = { name => $name, class => 'row_color_'.$class, }; push(@$rows,$hash); $class = ( $class eq 'even' ? 'odd' : 'even'); } $template->param(DATA => $rows);
Output:<TMPL_LOOP NAME=DATA> <tr> <td class="<TMPL_VAR NAME="class">"> Row <TMPL_VAR NAME="name"></td> </tr> </TMPL_LOOP>
<tr> <td class="row_color_odd"> Row Odd1</td> </tr> <tr> <td class="row_color_even"> Row Even1</td> </tr> <tr> <td class="row_color_odd"> Row Odd2</td> </tr> <tr> <td class="row_color_even"> Row Even2</td> </tr>
|
---|