On Fri, Jan 09, 2004 at 08:01:21AM -0800, LDT wrote: > I confess I don't completely understand what you suggested, but I tried the > following and I receive an error that says "nc_rpt_summary.pl: HTML::Template : > Attempt to set nonexistent parameter 'cell_fmt' - ..[blah].. at > /nc_rpt_summary.pl line 599". > I tried changing 'cell_fmt' in line 599 to > 'title_bar'. I also tried it as 'some_var' (just to see what would happen) and > the error message changes to reflect each variation I tried. I also tried > putting Lines 598 and 599 in front of Line 593. No luck on any of this. > > > Ln593: $tmpl_main->param(title_bar => "Rpt $rpt_no - $rpt_lbl", > hdr_asofdt => "$rpt_asofdt", > attr_fyr => $attr_fyr, > passattrs => [EMAIL PROTECTED], > passdata => [EMAIL PROTECTED]); > Ln598: my $big_tmpl = HTML::Template->new( scalarref => \$cell_fmt ); > Ln599: $big_tmpl->param( cell_fmt => $tmpl_main->output() ); > Ln600: print $tmpl_main->output(); > > And a shortened snipped version of my .tmpl file: > > <TMPL_LOOP NAME=passdata> > <tr class=<TMPL_VAR NAME=trclass> bgcolor=<TMPL_VAR NAME=bgcolor>> > <td <TMPL_VAR NAME=cell_fmt><TMPL_VAR NAME=col_cfte></td> > <td <TMPL_VAR NAME=cell_fmt><TMPL_VAR NAME=col_cbud></td> > </tr> > </TMPL_LOOP> >
Lori: The idea behind HTML::Template is that you pass it a reference to a hash and it uses the keys of the hash as the namespace for that template. Additionally, for TMPL_LOOP variables you pass a reference to an array as the value to one of the keys in the hash reference that your passing to the template. The new problem in your template is that you have not passed a value for all the variables in the template $tmpl_main. The default behavior for HTML::Template is to complain when a value for a template variable is not found in the hash reference that has been passed to it. This behavior can be turned off with die_on_bad_params=>0 passed to HTML::Temaplte->new. Additionally, inside a TMPL_LOOP, by default, other paramters are not visible. This can be changed by passing global_vars=>1 to new(). Also, it looks like you got things a bit confused between your two templates $tmpl_main and $big_tmpl. Now, I'm not quite sure of everything your trying to accomplish, but I think that you probably don't need the separate template for the cell format. And it looks like your trying to correlate the @loop_data and @loop_attrs arrays, which you can't in HTML::Template. You would have to put the data for each row in one hash reference and then all the rows in one array reference (for the TMPL_LOOP var). So for your code above this would work: #!/usr/bin/perl -w use strict; use HTML::Template; my $color1='white'; my $color2='red'; my @loop_data = ( { col_cfte => 'col_cfte_val1', col_cbud => 'col_cbud_val1', trclass=>'class1', bgcolor=>"$color1", }, { col_cfte => 'col_cfte_val2', col_cbud => 'col_cbud_val2', trclass=>'class1', bgcolor=>"$color2", }, { col_cfte => 'col_cfte_val3', col_cbud => 'col_cbud_val3', trclass=>'class1', bgcolor=>"$color1", }, ); my $big_tmpl = HTML::Template->new( die_on_bad_params=>0, global_vars=>1, filehandle => \*DATA, ); $big_tmpl->param( { title_bar => 'Rpt 1', hdr_asofdt => 'Today', attr_fyr => 'someval', passdata => [EMAIL PROTECTED], } ); print $big_tmpl->output; __DATA__ <TMPL_LOOP NAME=passdata> <tr class=<TMPL_VAR NAME=trclass> bgcolor=<TMPL_VAR NAME=bgcolor>> <td align="right" style="cursor:pointer;cursor:hand;" title="Click to drill down" onmouseover="style.background='#CCCCFF';" onmouseout ="style.background='<TMPL_VAR NAME=bgcolor>';" ><TMPL_VAR NAME=col_cfte></td> <td align="right" style="cursor:pointer;cursor:hand;" title="Click to drill down" onmouseover="style.background='#CCCCFF';" onmouseout ="style.background='<TMPL_VAR NAME=bgcolor>';" ><TMPL_VAR NAME=col_cbud></td> </tr> </TMPL_LOOP> Unless there is something else you are trying to accomplish here. Regards, Ron ------------------------------------------------------- This SF.net email is sponsored by: Perforce Software. Perforce is the Fast Software Configuration Management System offering advanced branching capabilities and atomic changes on 50+ platforms. Free Eval! http://www.perforce.com/perforce/loadprog.html _______________________________________________ Html-template-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/html-template-users