In my experiments with nested templates, I tried some trickery using associate to avoid the extra param() calls. However, I've come across an unexpected result (at least, unexpected to me).
The code below shows two templates (tmpl1 and tmpl2) each of which associate another template (borrow1 and borrow2, respectively). Apparently, the param() call only sets a value in a template if there is a corresponding TMPL_VAR--even with die_on_bad_params turned on. Is this intended? My expectation is that the param would be set in the object regardless, so that another call to param() to *get* the value would succeed. I tried adding global_vars => 1 after line 26, thinking that might be needed, but the result was the same. I'm at version 2.8. Regards, Brad 1 #!/usr/local/bin/perl 2 3 use strict; 4 use warnings; 5 use HTML::Template; 6 7 my $text = qq'This is a <TMPL_VAR NAME="color"> bird.\n'; 8 9 # ---- try 1 10 my $has = '<TMPL_VAR NAME="color">'; 11 my $borrow1 = HTML::Template->new( 12 scalarref => \$has, 13 ); 14 $borrow1->param( color => 'blue' ); 15 16 my $tmpl1 = HTML::Template->new( 17 scalarref => \$text, 18 associate => $borrow1, 19 ); 20 21 print "try1: " . $tmpl1->output(); 22 23 # ---- try 2 24 my $hasnot = 'dummy'; 25 my $borrow2 = HTML::Template->new( 26 scalarref => \$hasnot, 27 die_on_bad_params => 0, 28 ); 29 $borrow2->param( color => 'blue' ); 30 31 my $tmpl2 = HTML::Template->new( 32 scalarref => \$text, 33 associate => $borrow2, 34 ); 35 36 print "try2: " . $tmpl2->output(); 37 38 __END__ 39 try1: This is a blue bird. 40 try2: This is a bird. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Html-template-users mailing list Html-template-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/html-template-users