On Mon, 14 Apr 2008 18:03:53 +0100, Roger Burton West wrote > On Mon, Apr 14, 2008 at 07:38:03AM -0800, Alex Teslik wrote: > > >$template->param( > > OUTER_LOOP => [ > > { OUTER_VAR => 'I AM THE OUTER VAR' }, > > { INNER_LOOP => [ > > { INNER_VAR => 'I AM > > THE > >INNER VAR' }, > > ] > > }, > > ], > > ); > > Your data structure is wrong. > > Each entry in the OUTER_LOOP list is one element in the loop. You > have two elements; the first one only sets OUTER_VAR and the second > one only contains INNER_LOOP. So you're going round the loop twice, > and OUTER_VAR is undefined the second time round. Try this (not > checked): > > $template->param( > OUTER_LOOP => [ > { OUTER_VAR => 'I AM THE OUTER > VAR' , INNER_LOOP => [ { > INNER_VAR => 'I AM THE INNER VAR' }, > ] }, > ], ); > > Roger >
Hi Roger, Thank you for spotting that. That works as expected: ---- OUTER: I AM THE OUTER VAR INNER: I AM THE INNER VAR INSIDE OUT: I AM THE OUTER VAR ---- My next step was to then remove the outer_var from the outer_loop in the template, but still use it in the inner_loop in the template (as indicated in the changelog): <TMPL_LOOP OUTER_LOOP> <!-- no outer_var here anymore --> <TMPL_LOOP INNER_LOOP> INNER: <TMPL_VAR INNER_VAR> INSIDE OUT: <TMPL_VAR OUTER_VAR> </TMPL_LOOP> </TMPL_LOOP> but that does not work as expected: HTML::Template : Attempt to set nonexistent parameter 'outer_var' - this parameter name doesn't match any declarations in the template file : (die_on_bad_params => 1) at /usr/local/lib/perl5/site_perl/5.8.5/HTML/Template.pm 3068 at at test.pl line 30 It seems that unused outer_loop variables do not work in inner_loops as indicated in the changelog. Thanks, Alex ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ Html-template-users mailing list Html-template-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/html-template-users