Hi,

In my web application, whenever I instantiate a HTML::Template object, I
always set the same variables that contain often-used lists, for example the
list of months in the year, the list of days in a month, etc...

In any template, then, I can have the following contruct (code sample 1):

<SELECT NAME="Whatever">
<TMPL_LOOP NAME="One of the 'list' variables">
<OPTION VALUE="the value">the text
</TMPL_LOOP>
</SELECT>

So far, this is basic.

Now, one of my templates lists a series of candidates for a job opening.
For each candidate, a lot of different information fields are displayed.
The template has the following structure (code sample 2):

<TABLE>
<TMPL_LOOP NAME=CANDIDATES>

<TR>
[the candidate's information, made up of many sub-tables, etc...]
</TR>

</TMPL_LOOP>
</TABLE>


I would like to use one of my "permanent" lists (mentionned at the start of
this post) inside each candidate's information structure.  However,
inserting "code sample 1" anywhere inside the <tr></tr> of "code sample 2"
yields an empty list.  Of course, manually adding the permanent list to the
CANDIDATES list resolves the problem.

Is it by design that I cannot use a TMPL_LOOP construct inside another one
in a template ?

A funny behavior is that if I insert "code sample 1" before the <TMPL_LOOP>
of "code sample 2", and then use "code sample 1" inside the <TR></TR>, then
everything seems fine.

Here's my instantiation code for the HTML::Template object :

$self->{html_template} = new HTML::Template(scalarref => \$the_template,
                                              option => 'value',
                                              die_on_bad_params => 0,
                                              global_vars => 1,
                                              loop_context_vars => 1);

Reply via email to