Loop index

Dermot <paikkos-gM/[email protected]>
Newsgroups gmane.comp.lang.perl.modules.template-toolkit
Message-ID <CAK+UtvLxnN43LVwrqOU_uPbKd91K_=Qtn0d0vZYNhha=YKGAjw@mail.gmail.com>
Hi,

I hope I not being either lazy or dim but I can't seem to get this.

I am creating a table (I can't use the table plugin, the data does
suit) and need to access array elements after they have gone out of
scope. In the table below, I write the table headers from the array x,
finish with array x and start writing the rows. As I am writing out
the td's in each row I need to refer their column. I thought that
loop.index might help, I had hoped I could do x.loop.index to grab the
nth element from the header array. Alas not. I can't seem to find a
way to interpolate the loop.index and array, EG x.loop.index will not
work.  Does anyone have any advice, I struggling today.
Thanks,
Dermot.


           <table border="1" >
               <tr>
                   <th></th>
                   [% FOREACH th IN x  %]
                       <th>[% th.value | html %]</th>
                   [% END %]
                   </tr>
                   [% FOREACH cell IN y %]
                       <tr><td>[% cell.value | html %]</td>[% FOREACH
cell IN y %]
                           <td>[% idx = loop.index %]
                           <input type="text" name="foo" value="[%
x.idx  %]" />
                           </td>[% END %]
                       </tr>
                   [% END %]
          </table>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.