Guys,
Okay, so I find myself writing quite a lot of this:
[% FOREACH thing = buncha.things %]
[% IF loop.count % 2 == 1 %]
do the odd rows
[% ELSE %]
do the even rows
[% END %]
[% END %]which of course doesn't bother _me_ one whit, but it makes absolutely no sense to Jen, my non-programming template designer. So I'm thinking that something like:
[% FOREACH thing = buncha.things %]
[% IF loop.odd %]
do the odd rows
[% ELSE %]
do the even rows
[% END %]
[% END %]would be very cool for her. And it seems like it'd be trivial to implement.
Now, in the badger book, in the section on Template::Iterator, I can see how to create a class to do what I want. Seems pretty basic. What I'm wondering is is there any (reasonably simple) way to install this functionality so that I can get it for every loop? I'd rather not have to replace all my arrayrefs with functions that return a special iterator; I think that'd negate the convenience to Jen with the inconvenience to me. So I _think_ what I want to do is override the default iterator. But I don't see how to do that. (Or maybe I'm on the wrong track altogether.)
Any thoughts?
-- Buddy
_______________________________________________ templates mailing list [EMAIL PROTECTED] http://lists.template-toolkit.org/mailman/listinfo/templates
