Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: HTML::Template __even__

by Anonymous Monk
on Jun 04, 2014 at 17:29 UTC ( [id://1088691]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1088691]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-03-28 17:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found