[Catalyst] pass array to template?
Sarah Berry
berry.sarah at gmail.com
Wed Jun 28 21:43:44 CEST 2006
How can I pass an array to Template Toolkit, then loop through it? I'm
trying to pass it through the stash just like anything else, as
follows:
in .pm file:
my @numtextCaps = ("Zero", "One", "Two", "Three", "Four",
"Five", "Six", "Seven", "Eight");
$c->stash->{numarray} = @numtextCaps;
in .tt file:
[% FOREACH word = numarray %]
<h3>[% word %]</h3>
[% END %]
The loop only iterates once, and prints out:
9
at that one iteration.
My code seems to match the way the foreach loop is done in the
Template Toolkit documentation, so I must be missing something in the
way TT interacts with Catalyst?
Thanks,
Sarah
More information about the Catalyst
mailing list