On Fri, 21 Mar 2003, darren chamberlain wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > * Clayton L. Scott <tex at engsoc.org> [2003-03-21 13:37]: > > After so much success with me writing what I thought would work and TT > > just Doing What I Mean I was surprised when loop.count didn't work > > here in a WHILE loop like so: > > > > [% WHILE ( obj = iterator.next ) %] > > [% rowAttr = loop.count mod 2 ? '' : 'class="altRow"' %] > > > > <tr[% " $rowAttr" %]> > > <td> [% obj.something %]</td> > > <td> [% obj.otherthing %]</td> > > </tr> > > [% END %] > > But this is exactly what a FOREACH loop is, so just rewrite your code: > > [% FOREACH obj = iterator.next %]
I thought so too. But it doesn't work. The iterator in question is a Class::DBI::Iterator and not a Template::Iterator, my apologies for not making that clear. Template::Iterator makes an iterator containing the single item returned from the iterator.next call. I probably could rewrite it as [% FOREACH obj = cdbiiterator %] but that's breaking encapsulation of the object and it's not guaranteed to work the next time the internals of Class::DBI::Iterator change. It would still be nice if loop.count worked in a WHILE. Clayton _______________________________________________ templates mailing list [EMAIL PROTECTED] http://lists.template-toolkit.org/mailman/listinfo/templates
