Craig Barratt <[EMAIL PROTECTED]> writes:

> > How can I access methods from the Template::Iterator object?
> > ie. i would like:
> > 
> > [% FOREACH letter = ['a','b','c'];
> >      letter.count;
> >    END %]
> > 
> > to output 123.
> > 
> > I know that the count() method doesn't belong to the array value, but I
> > can't see which object it belongs to inside the template.
> 
> Use loop.count.  See Template::Manual::Directives.
>

Thanks,

I can now do:

<tr bgcolor="[% loop.count mod 2 ? 'red' : 'gray' %]"> ... </tr>

to alternate colors in a table, and

[% loop.count; ". "; section.name %]

to number the sections.



Reply via email to