Hello y'all. I'm trying to do a nested loop in HTML::Template. My webapp grabs a list of directories and a bunch of files from those directories. I wish to display a table which includes the directory name followed by rows of 5 filenames (each one in a column). My current template is as follows:
<html> <head> <title><TMPL_VAR NAME="title"></title> </head> <body> <center> <table> <TMPL_LOOP NAME="dir_loop"> <tr> <th colspan="5" bgcolor="#E0E0E0"><font size="+3"><TMPL_VA +R NAME="dir"></font></th> </tr> <TMPL_LOOP NAME="outter_file_loop"> <tr> <TMPL_LOOP NAME="inner_file_loop"> <td colspan="5"><TMPL_VAR NAME="filename"></td> </TMPL_LOOP> </tr> </TMPL_LOOP> </TMPL_LOOP> </table> </center> </body> </html>
It starts with the dir_loop -- for each dir. The outter_file_loop is for each row, and the inner_file_loop is for each item in the row. My questions are as follows: Does the template look like it would work? If so, how would I construct the array & hashes to make it work? Is there a better way to do it (<- this should probably be asked first)? Thanks in advance. -Brian

In reply to Nested loops in HTML::Template 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.