Re: [Templates] Overriding the default iterator
[prev]
[thread]
[next]
[Date index for 2004/09/03]
Of course, there's always Template::Plugin::Cycle, designed for just
your sort of situation... especially if you just want row backgrounds
and such.
<tr class="[% row %]">
... returns different values each time, cycling around the values (
typically 2 of course, although it's flexible enough to use in a variety
of other situations )
Adam K
Buddy Burden wrote:
> 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
> templates@xxxxxxxxxxxxxxxx.xxx
> http://lists.template-toolkit.org/mailman/listinfo/templates
_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates
 |
 |
Re: [Templates] Overriding the default iterator
Adam Kennedy 05:31 on 03 Sep 2004
|