On Thu, Oct 28, 2004 at 07:16:53AM -0500, Andy Lester wrote:
> >
> >
> >[% count = 0;
> >    WHILE ($sth->fetchrow_arrayref) %]
> >        [% IF ($count % 2) %]
> >            print "something";
> >        [% ELSE %]
> >            print "something else";
> >        [% END %]
> >    count++;
> >[% END %]
> 
> Yes, that's correct.
> 
> And, if you're trying to print alternating background colors for your 
> rows, please just set a variable for the color, rather than having two 
> nearly identical print statements.

One important thing to note here is that when using a WHILE loop you
have to ensure you do not exceed 1000 iterations. If you need more
than that you will have to alter $Template::Directive::WHILE_MAX. It
might be better to recode using an iterator and a FOREACH loop. With
the FOREACH you would also have access to the loop.* variables for
free. You can then do away with the separate count variable and just
use loop.count

Stephen






_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to