Can anyone see why this nested loop is broken?

Update: I changed the template VAR_NAMES and got it working. I'm still not able to figure out why the original case is broken.

Update (again): The problem was the lack of quoting the VAR_NAMEs.

#!/usr/bin/perl use strict; use HTML::Template; my $tmpl_obj = HTML::Template->new( filename => 'test.tmpl', case_sensitive => 1, ); $tmpl_obj->param( OUTER_LOOP => [ { MENU_NAME => "GONZO", INNER_LOOP => [ { SUBSCRIPT_ACTION => "javascript://", SUBSCRIPT_NAME => "test1", }, { SUBSCRIPT_ACTION => "javascript://", SUBSCRIPT_NAME => "test2", }, { SUBSCRIPT_ACTION => "javascript://", SUBSCRIPT_NAME => "test3", }, ], }, ], ); print $tmpl_obj->output();
### Contents of test.tmpl
<ul id="sddm"> <TMPL_LOOP NAME=OUTER_LOOP> <li><a href="#" onmouseover="mopen('m1')" onmouseout="mclosetime()"><TMPL_VAR NAME=MENU_NAME></a> <div id="m1" onmouseover="mcancelclosetime()" onmouseout="mclosetime()"> <TMPL_LOOP NAME=INNER_LOOP> <a href=<TMPL_VAR NAME=SUBSCRIPT_ACTION>><TMP_VAR NAME=SUBSCRI +PT_NAME></a> </TMPL_LOOP> </div> </TMPL_LOOP> </ul> <div style="clear:both"></div>

In reply to HTML::Template with nested loops by mhearse

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.