Re: [htmltmpl] TMPL_VAR inside a TMPL_VAR
Brought to you by:
samtregar
From: LDT <per...@ya...> - 2004-01-09 15:08:09
|
Thanks for the explanation. I tried it right away, and I now get the following error. I had snipped out the parameters in my original post because they were irrelevant, but now it trips over them in my actual program. I haven't changed any of my templates, so I believe this is in response to the scalarref stuff I'm trying to do. nc_rpt_summary.pl: HTML::Template : Attempt to set nonexistent parameter 'title_bar' - this parameter name doesn't match any declarations in the template file : (die_on_bad_params => 1) at /local/www/htdocs/scripts/campus/nc_rpt_summary.pl line 594 And here's the complete code section I'm using (I went back to the HERE doc, but the q and qq don't work either): my $cell_fmt = <<EOL align="right" style="cursor:pointer;cursor:hand;" title="Click to drill down" onmouseover="style.background='#CCCCFF';" onmouseout ="style.background='<TMPL_VAR NAME=bgcolor>';"> EOL ; $tmpl_main = HTML::Template->new( scalarref => \$cell_fmt ); $tmpl_main->param( title_bar => "Rpt $rpt_no - $rpt_lbl", hdr_asofdt => "$rpt_asofdt", attr_fyr => $attr_fyr, passattrs => \@loop_attr, passdata => \@loop_data); print $tmpl_main->output(); I also tried changing the order of the parameters passing to the template, but that didn't make it work (I tried putting the "new" after "param"). BTW, your <TMPL_INCLUDE> suggestion will work, and I'll use that if I can't get this to work. I wanted to try and avoid the TMPL_INCLUDE because I end up with a reference/link inside of a reference/link (and I'll have another reference/link in the future when I get the drill down set up) and I want to keep my code as maintainable (and readable) as possible. Or, am I being too picky? Timm Murray <tm...@ag...> wrote: scalarref takes just that: a reference to a scalar. So you almost got it: $tmpl_main = HTML::Template->new( scalarref => \$cell_fmt ); At 06:27 AM 1/9/04 -0800, LDT wrote: >Hi Timm, > >Thanks for the quick response. I looked at the H:T documentation, and I >see the reference to scalarref and arrayref, but I don't understand what >they mean or exactly how I might use them. If I understand your note >correctly, I would need add the scalarref like this: > >my $cell_fmt = qq (align="right" style="cursor:pointer;cursor:hand;" > title="Click to drill down" > onmouseover="style.background='#CCCCFF';" > onmouseout ="style.background='> NAME=bgcolor>';"> > ); >$tmpl_main = HTML::Template->new( scalarref => $cell_fmt ); > >However, I get the following error: "nc_rpt_summary.pl: Can't use string >("align="right" style="cursor:poin") as a SCALAR ref while "strict refs" >in use at /usr/local/lib/perl5.8.0/site_perl/HTML/Template.pm line 1597." > >I've also tried using just a "q", using a HERE doc, and I get pretty much >the same error each time. So, obviously, I'm using it incorrectly but I >don't understand why. Any ideas? If you're willing, would you give me a >dumbed down version? ;-) > >Thanks! > >Lori Thompson > >Timm Murray wrote: >At 02:14 PM 1/8/04 -0800, LDT wrote: ><> > >Am I missing something, or am I trying to do something naughty? > >HTML::Template won't expand entries that were placed into >another . What you probably want is a >. Alternatively, you can create another HTML::Template >object out of the data inlined in your program now via the scalarref >parameter. You can fill in this data as normal, and then pass its output >to the main template's . Love, Lori --------------------------------- Do you Yahoo!? Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes |