John,

# Want to mimic this in template:
for ([EMAIL PROTECTED]) {
print "<tr>" if $_ == 0;
print "<td>$aref->[$_]{id}</td>";
print "</tr>\n<tr>" unless ($_+1)%4;
print "</tr>" if $_ == [EMAIL PROTECTED];
}

I would do it something like this:

        <tr>
                [% FOREACH a IN aref %]
                        <td>[% a.id %]</td>
                        [% IF loop.count % 4 %]
        </tr>
        <tr>
                        [% END %]
                [% END %]
        </tr>

I usually "outdent" stuff like that because it lines up the <tr>'s with their correspoding </tr>'s and it also quickly helps me notice that the loop can generate more than one table row. But do it however you like.

Note that since this is HTML, I'm assuming you don't really absolutely need each table row to be exactly one line. If I'm wrong about that, you'd have to squash it together a lot more and/or get rather creative with [%- and -%]. But hopefully that's not the case.

HTH.


                -- Buddy

_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to