in reply to Loop Context Style with HTML::Template
Couple this with a map and you can add a different class for every row of data. Now, i don't agree with storing the style sheet info inside the script, after all, you want the others in your group to maintain that part. Having said all of that, here is my example:perl -le '@a = a..d; print $a[$i++ % @a] for 0..15'
So, the code is a little more complex, but not terribly more and definitely at the expense of making the template less complex. I am sure the others in your group will appreciate it. :)use strict; use HTML::Template; my $data = do {local $/; <DATA>}; my $tmpl = HTML::Template->new(scalarref => \$data); my $rows = [ { col1 => 'Graham Chapman', col2 => 'John Cleese' }, { col1 => 'Terry Gilliam', col2 => 'Eric Idle' }, { col1 => 'Terry Jones ', col2 => 'Michael Palin' }, { col1 => 'Terry Jones ', col2 => 'Michael Palin' }, { col1 => 'Terry Gilliam', col2 => 'Eric Idle' }, ]; my $i = 0; my @class = qw(one two three); $tmpl->param( rows => [ map { { %$_, class => $class[$i++ % @class] } } @$rows ], ); print $tmpl->output; __DATA__ <style type="text/css"> <!-- table { border-spacing: 0px; } td { padding: 3px; } td.one { background-color: #c0c0c0; } td.three { background-color: #e0e0e0; } td.two { background-color: #d0d0d0; } --> </style> <table> <tmpl_loop rows> <tr> <td class="<tmpl_var class>"> <tmpl_var col1> </td> <td class="<tmpl_var class>"> <tmpl_var col2> </td> <tr> </tmpl_loop> </table>
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|