FOREACH question
Mark Haney <markh-rOuQeLG7NUhWk0Htik3J/[email protected]> Thu, 23 Aug 2012 08:15:12 -0400
| Newsgroups | gmane.comp.lang.perl.modules.template-toolkit |
|---|---|
| Message-ID | <[email protected]> |
I have a question regarding the FOREACH loops. I have a FOREACH being used to loop through an array to insert various images into a table. Like this: > > [% FOREACH light IN lights %] > <td> > <img src="[% light.light_red %]"> > <img src="[% light.light_yellow %]"> > <img src="[% light.light_green %]"> > <img src="[% light.light_blue %]"> > </td> > > [% END %] What I need to do now is to loop through each element in the array (like a counter) and insert the images into it's own table. Like this: FOR a <= 3 <table> <tr> <td> <img src="[% light.[$a] %]"> </td> </tr> </table> a= a++ NEXT The problem is I don't know how to tell it the number of elements in the array (in this instance it will always be 4). Keep in mind that this code is inside an HTML template, so I don't really want any perl in it if I can help it. Any ideas? -- Mark Haney Software Developer/Consultant AB Emblem markh-rOuQeLG7NUhWk0Htik3J/[email protected] Linux marius.homelinux.org 3.5.1-1.fc17.x86_64 GNU/Linux