First off, it helps if you actually post code that works as-is (the __END__ marker with the *DATA filehandle is very handy for this). Or, in this case, doesn't work, but is at least in a state that can show what you mean...

Next, that's pretty messy. Why are you looping through and then checking for only one particular value? Without testing, I think you mean:

<!-- you only use 'foo', so why loop and check for it? --> <tr><td>foo</td>[% data.main.ResultSet.Listing.foo %]</tr> [% FOREACH l IN data.main.ResultSet.Listing %] <tr><td>test 3</td>[% l.url.content %]</tr> [% END %]
There's only one place in your sample where you're not only looping, but you're using all the values you loop over. The rest seem to be hard-coded...


In reply to Re: Template Toolkit's FOREACH by Tanktalus
in thread Template Toolkit's FOREACH by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.