in reply to Re: HTML::Template __even__
in thread HTML::Template __even__

That would not work since it is inside of a loop. Can you post some code to show what you are saying? Thanks!

Replies are listed 'Best First'.
Re^3: HTML::Template __even__
by tangent (Parson) on Jun 04, 2014 at 18:22 UTC
    RonW is correct - what you are trying will not work. You would be better setting the class in Perl:
    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);
    Then in your template:
    <TMPL_LOOP NAME=DATA> <tr> <td class="<TMPL_VAR NAME="class">"> Row <TMPL_VAR NAME="name"></td> </tr> </TMPL_LOOP>
    Output:
    <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>
Re^3: HTML::Template __even__
by muba (Priest) on Jun 04, 2014 at 18:00 UTC

    Sure it would. You'll need two different classes, and then inside the loop select one of them using the TMPL_IF __even__ and __odd__ template constructs.