At 19:42 03/05/2002, Poulin Jacques wrote:
>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);

same problem as "Several Nested Loops, Variables Not Displaying" and some 
previous mails, i think - see following from Sam Tregar >>>>>>>>>>

 > Not sure whether this is a major problem (or a feature!) - only available
 > in v2.5 since you sorted outer loop variables to be accessible from an
 > inner loop (a great boon - many thanks!). It appears that a  variable from
 > an outer loop is only visible to the inner loop, with global_vars=>1, if it
 > has been referred to in the outer loop.

I think it's a bug, but it's probably an old one.  The problem is that
HTML::Template only makes "slots" for variables that it finds during
_parse().  So when you call param() to set SHEET => [ { SHEETNAME => "foo"
} ] there's noplace to put this variable.  I'd like to fix it but I'm not
sure how soon I can.  Until then you can work around it with this in your
outer loop:

   <!-- <tmpl_var sheetname> -->

It's a hack, but it should work.

-sam

<<<<<<<<<<<<<
cheers, Craig


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to