html-template-users Mailing List for HTML::Template (Page 60)
Brought to you by:
samtregar
You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(42) |
Jul
(80) |
Aug
(77) |
Sep
(97) |
Oct
(65) |
Nov
(80) |
Dec
(39) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(63) |
Feb
(47) |
Mar
(45) |
Apr
(63) |
May
(67) |
Jun
(51) |
Jul
(78) |
Aug
(37) |
Sep
(45) |
Oct
(59) |
Nov
(50) |
Dec
(70) |
2004 |
Jan
(23) |
Feb
(90) |
Mar
(37) |
Apr
(53) |
May
(111) |
Jun
(71) |
Jul
(35) |
Aug
(58) |
Sep
(35) |
Oct
(35) |
Nov
(35) |
Dec
(20) |
2005 |
Jan
(51) |
Feb
(19) |
Mar
(20) |
Apr
(8) |
May
(26) |
Jun
(14) |
Jul
(49) |
Aug
(24) |
Sep
(20) |
Oct
(49) |
Nov
(17) |
Dec
(53) |
2006 |
Jan
(12) |
Feb
(26) |
Mar
(45) |
Apr
(19) |
May
(19) |
Jun
(13) |
Jul
(11) |
Aug
(9) |
Sep
(10) |
Oct
(16) |
Nov
(17) |
Dec
(13) |
2007 |
Jan
(9) |
Feb
(12) |
Mar
(28) |
Apr
(33) |
May
(12) |
Jun
(12) |
Jul
(19) |
Aug
(4) |
Sep
(4) |
Oct
(5) |
Nov
(5) |
Dec
(13) |
2008 |
Jan
(6) |
Feb
(7) |
Mar
(14) |
Apr
(16) |
May
(3) |
Jun
(1) |
Jul
(12) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
(9) |
2009 |
Jan
(9) |
Feb
|
Mar
(10) |
Apr
(1) |
May
|
Jun
(6) |
Jul
(5) |
Aug
(3) |
Sep
(7) |
Oct
(1) |
Nov
(15) |
Dec
(1) |
2010 |
Jan
|
Feb
|
Mar
|
Apr
(9) |
May
|
Jun
|
Jul
(5) |
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
(3) |
Mar
|
Apr
(28) |
May
|
Jun
|
Jul
(3) |
Aug
(4) |
Sep
(3) |
Oct
|
Nov
(8) |
Dec
|
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
(2) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
|
2016 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
From: Paul B. <pb...@wh...> - 2004-02-09 21:44:18
|
I found a bug in the latest version of HTML::Template (2.6 and at least also 2.5) where if you have escape='url' in a <tmpl_var> tag, HTML escaping is done instead. This happens because although the main parsing regex checks for double and single quotes around url, later when another regex is used to test if an HTML escape or URL escape was used, it only checks for ESCAPE=URL or ESCAPE="URL". So if you have ESCAPE='URL' it is treated as though the default HTML escaping was specified. I submitted a patch for this on SourceForge last week, but since there hasn't been any activity, I thought I should post to the mailing list as well. The url for the patch tracker entry is: http://sourceforge.net/tracker/index.php? func=detail&aid=889386&group_id=1075&atid=301075 -- Paul Baker "Reality is that which, when you stop believing in it, doesn't go away." -- Philip K. Dick GPG Key: http://homepage.mac.com/pauljbaker/public.asc |
From: Chris F. <cf...@do...> - 2004-02-09 21:23:01
|
Sam Said, > Interesting. I've never tried to associate one template with another > one, but I would expect it to work. Can you put together a small test > script that generates this error? > Doh!! I appear to be all set Sam.. I couldn't easily take my existing code out as an example as its spread across 2 modules so I spent a few mins creating a test script. When I finished, it worked just fine.. To make a long story short, the loop wasn't being properly defined due to a earlier change, the "associate" had nothing to do with it - I just had a brain lapse between making a change and trying to get something new to work. Sorry about that, but hey... Its working now :).. I'm using Sebastien's suggestion of: my $t2 = new HTML::Template(filename => "email_purchase_results.tmpl", associate => $t1, ); I have a bunch of places where (like a shopping cart) the user is selecting multiple things through multiple form pages, once its done and everything is displayed to the user for conformation/receipt, I have to email it to multiple parties (again like a shopping cart). Using the above I can now have multiple email templates which I can assign all the values of what was just displayed, add some params if needed etc.. and just send it off as a HTML email... No more logic and nothing more then a couple of extra lines of code to do emails!! Maybe nothing special to some, or should have been obvious to me - but I wish I figured this out about a year ago as I would have saved hours upon hours of specialized email creation code, never mind about 5000 db hits a day that I will just go away!! Sam, you're the man.. H::T is awesome!! Thanks -Chris |
From: Sam T. <sa...@tr...> - 2004-02-09 18:30:47
|
On Mon, 9 Feb 2004, Chris Faust wrote: > That "associate" seemed like the way to go, when I tried that I get the H:T > error > "attempt to set parameter 'items_loop' with a scalar - parameter is not a > TMPL_VAR!" Interesting. I've never tried to associate one template with another one, but I would expect it to work. Can you put together a small test script that generates this error? > When I tried the "$content2->param($content->param);" method That won't work because param() without any args returns a list of parameter names, no values. Try something like this: $content2->param(map { ($_, $content->param($_)) } $content->param()); That takes a list of param names and uses map{} to build a list of (name,value) pairs to pass to param(). -sam |
From: <hat...@tu...> - 2004-02-09 15:24:26
|
Hello Chris, Monday, February 9, 2004, 5:11:34 PM, you wrote: >> It's even simpler: simply associate the first object with the second. >> #!/usr/bin/perl >> use HTML::Template; >> my $tmpl = new HTML::Template filehandle => \*DATA; >> $tmpl->param(foo => "bar"); >> print $tmpl->output; >> my $str = "Second template: foo = <TMPL_VAR NAME=foo>\n"; >> my $copy = new HTML::Template scalarref => \$str, associate => $tmpl; >> print $copy->output; I think that this can be done more simply: my $copy = new HTML::Template associate => $tmpl; but if I'm not mistaken, when you will call $tmpl->param(foo => 'bar') later, you'll get this param also in $copy -- Best regards, Ãîðüêèé Þðèé mailto:hat...@tu... |
From: Chris F. <cf...@do...> - 2004-02-09 15:11:56
|
Roger Burton West wrote: > I haven't tried this, but my first reaction is to use the usual syntax > for interrogating a template: > > $content2->param($content->param); Sébastien Aperghis-Tramoni wrote: > It's even simpler: simply associate the first object with the second. > #!/usr/bin/perl > use HTML::Template; > my $tmpl = new HTML::Template filehandle => \*DATA; > $tmpl->param(foo => "bar"); > print $tmpl->output; > my $str = "Second template: foo = <TMPL_VAR NAME=foo>\n"; > my $copy = new HTML::Template scalarref => \$str, associate => $tmpl; > print $copy->output; Thanks for the suggestions guys, I tried both ways and I got different results with each. That "associate" seemed like the way to go, when I tried that I get the H:T error "attempt to set parameter 'items_loop' with a scalar - parameter is not a TMPL_VAR!" When I tried the "$content2->param($content->param);" method - I'm not really sure what happened, it failed when trying to set a tmpl_var that was the "else" in $content, but $content already contained the flag to mark that value true, plus it seemed to process forever, it took about 2 mins.. I'm going to keep experimenting and see if I can get something to work, if you have any other idea, I'd love to hear them. Thanks -Chris |
From: <sa...@es...> - 2004-02-08 18:13:21
|
Roger Burton West wrote: > On Sun, Feb 08, 2004 at 12:40:45PM -0500, Chris Faust wrote: >> Seriously, this may be a silly or even stupid question - but is there=20= >> some way to create a new template object and simply assign it all the=20= >> params as a existing template object? > > I haven't tried this, but my first reaction is to use the usual syntax > for interrogating a template: > > $content2->param($content->param); It's even simpler: simply associate the first object with the second. #!/usr/bin/perl use HTML::Template; my $tmpl =3D new HTML::Template filehandle =3D> \*DATA; $tmpl->param(foo =3D> "bar"); print $tmpl->output; my $str =3D "Second template: foo =3D <TMPL_VAR NAME=3Dfoo>\n"; my $copy =3D new HTML::Template scalarref =3D> \$str, associate =3D> = $tmpl; print $copy->output; __END__ First Template: foo =3D <TMPL_VAR NAME=3Dfoo> =3Dcut will print: $ perl associate.pl First Template: foo =3D bar Second template: foo =3D bar S=E9bastien Aperghis-Tramoni -- - --- -- - -- - --- -- - --- -- - --[ http://maddingue.org ] Close the world, txEn eht nepO= |
From: Chris F. <cf...@do...> - 2004-02-08 18:07:32
|
Thanks Roger, I'll give that a try and see what happens. -Chris ----- Original Message ----- From: "Roger Burton West" <ro...@fi...> To: <htm...@li...> Sent: Sunday, February 08, 2004 12:51 PM Subject: Re: [htmltmpl] New Template Object based on Existing one > On Sun, Feb 08, 2004 at 12:40:45PM -0500, Chris Faust wrote: > >Seriously, this may be a silly or even stupid question - but is there some way to create a new template object and simply assign it all the params as a existing template object? > > I haven't tried this, but my first reaction is to use the usual syntax > for interrogating a template: > > $content2->param($content->param); > > Roger > > > ------------------------------------------------------- > The SF.Net email is sponsored by EclipseCon 2004 > Premiere Conference on Open Tools Development and Integration > See the breadth of Eclipse activity. February 3-5 in Anaheim, CA. > http://www.eclipsecon.org/osdn > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users > |
From: Roger B. W. <ro...@fi...> - 2004-02-08 17:51:47
|
On Sun, Feb 08, 2004 at 12:40:45PM -0500, Chris Faust wrote: >Seriously, this may be a silly or even stupid question - but is there some way to create a new template object and simply assign it all the params as a existing template object? I haven't tried this, but my first reaction is to use the usual syntax for interrogating a template: $content2->param($content->param); Roger |
From: Chris F. <cf...@do...> - 2004-02-08 17:41:03
|
Hey All, I haven't seen a message posted since the 21st, so I wanted to make sure = everything was still working :) Seriously, this may be a silly or even stupid question - but is there = some way to create a new template object and simply assign it all the = params as a existing template object? Something like **** my $content =3D new HTML::Template(filename =3D> "template1.tmpl"); Go through and set all kinds of params my $content2 =3D new HTML::Template(filename =3D> "template2.tmpl"); $content2->param(%$content); $content2 now contains all the params and values that were/are in = $content. **** I know that wouldn't work, just hoping it would help explain. Thanks -Chris |
From: <hat...@tu...> - 2004-01-21 12:10:15
|
Hello html-template-users, I wonder if there is a possibility to get the count of iterations in a loop. <TMPL_VAR __counter__> returns the number of current iteration. of course, I know that I always can do param() to put this into a template, but may be there is an other way... -- Best regards, Горький Юрий mailto:hat...@tu... |
From: Ron M. <rma...@in...> - 2004-01-13 17:08:11
|
On Tue, Jan 13, 2004 at 05:56:11AM -0800, LDT wrote: > Thanks for the reply, Ron. ... > I had tried to add the $cell_fmt to my @loop_data (which is fed into the TMPL_LOOP on the main template), but it didn't like that either (undoubtedly it was the way I was trying to add it). I am curious about this piece of your code: filehandle => \*DATA. What does this do? The parts I understand are that you're setting up file handle, the "\" is a reference, and the "DATA" is referenced to the section below. My guess would be that this is how you're passing the formatting stuff to the template. Is that right? A perl script can have a "data" section, anything that follows the __DATA__ tag in the script file. The part with \*DATA is a reference filehandle to that data section. Its a nifty little trick that I use to test out templates in the same file as a script. I'm glad you found a solution to your problem. Ron. |
From: LDT <per...@ya...> - 2004-01-13 13:56:17
|
Thanks for the reply, Ron. I'll try to answer your questions. I ended up just using a TMPL_INCLUDE to handle it since it was taking me so long to figure it out (and the reports are due 2-1-04, and this is just the first one). However, I really appreciate your taking the time to explain to me why it didn't work. That helps me (and future folks searching the archives) to understand how things like TMPL_VAR work. I already had global_vars set to 1 (I think I had snipped that out in my first post - my bad). My goal was the take a scalar ($cell_fmt) and pass it to the main template. However, the $cell_fmt scalar had a TMPL_VAR inside it, and I learned that H:T won't interpret it in "layers" (which prompted my initial post). The "big_tmpl" stuff was something I was trying that someone else had suggested but I didn't understand him. I ended up deleting all the "big_tmpl" stuff, and going with the TMPL_INCLUDE. I had tried to add the $cell_fmt to my @loop_data (which is fed into the TMPL_LOOP on the main template), but it didn't like that either (undoubtedly it was the way I was trying to add it). I am curious about this piece of your code: filehandle => \*DATA. What does this do? The parts I understand are that you're setting up file handle, the "\" is a reference, and the "DATA" is referenced to the section below. My guess would be that this is how you're passing the formatting stuff to the template. Is that right? I'm not trying to correlate the two arrays in the template. The @loop_attr actually goes into one of the main template's TMPL_INCLUDEs (and then into it's own TMPL_LOOP) and really has nothing to do with @loop_data (they each have their own TMPL_LOOP). The final .pl code is about 450 lines; the templates all total are about 100 lines. If you want to see it, let me know and I'll send it. Thanks again for taking the time to help me! Lori Thompson Ron Mahoney <rma...@in...> wrote: 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 => \@loop_data, } ); print $big_tmpl->output; __DATA__ bgcolor=> style="cursor:pointer;cursor:hand;" title="Click to drill down" onmouseover="style.background='#CCCCFF';" onmouseout ="style.background='';" > style="cursor:pointer;cursor:hand;" title="Click to drill down" onmouseover="style.background='#CCCCFF';" onmouseout ="style.background='';" > Unless there is something else you are trying to accomplish here. Regards, Ron --------------------------------- Do you Yahoo!? Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes |
From: Ron M. <rma...@in...> - 2004-01-12 16:38:21
|
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 => \@loop_attr, > passdata => \@loop_data); > 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 => \@loop_data, } ); 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 |
From: Bill M. <wpm...@co...> - 2004-01-12 00:46:25
|
Hi all, I'm looking for a Delphi component similar to H::T. I found 'HTML Template' but I don't really care for it. I'm looking for something that is flexible in terms of where the data comes from, and of course, open source. The RAVE component that ships with D7 looks awfully complicated, but I'm looking into this as well. Thanks, Bill |
From: LDT <per...@ya...> - 2004-01-09 16:01:27
|
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 => \@loop_attr, passdata => \@loop_data); 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> Timm Murray <tm...@ag...> wrote: At 07:08 AM 1/9/04 -0800, LDT wrote: <> >my $cell_fmt = <>align="right" style="cursor:pointer;cursor:hand;" > title="Click to drill down" > onmouseover="style.background='#CCCCFF';" > onmouseout ="style.background='> 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(); $tmpl_main only gets parameters that are visible inside $cell_fmt. Once those are set, you can put its output into the parameter of another template like this: my $big_tmpl = HTML::Template->new( . . . ); $big_tmpl->param( some_var => $tmpl_main->output() ); --------------------------------- Do you Yahoo!? Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes |
From: Timm M. <tm...@ag...> - 2004-01-09 15:15:35
|
At 07:08 AM 1/9/04 -0800, LDT wrote: <> >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(); $tmpl_main only gets parameters that are visible inside $cell_fmt. Once those are set, you can put its output into the parameter of another template like this: my $big_tmpl = HTML::Template->new( . . . ); $big_tmpl->param( some_var => $tmpl_main->output() ); |
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 |
From: Timm M. <tm...@ag...> - 2004-01-09 14:37:16
|
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='<TMPL_VAR > 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 <tm...@ag...> 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 . > > >Do you Yahoo!? >Yahoo! Hotjobs: ><http://pa.yahoo.com/*http://us.rd.yahoo.com/hotjobs/mail_footer_email/evt=21482/*http://hotjobs.sweepstakes.yahoo.com/signingbonus>Enter >the "Signing Bonus" Sweepstakes |
From: LDT <per...@ya...> - 2004-01-09 14:27:55
|
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='<TMPL_VAR 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 <tm...@ag...> 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 . --------------------------------- Do you Yahoo!? Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes |
From: Timm M. <tm...@ag...> - 2004-01-08 22:29:44
|
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 <TMPL_VAR> entries that were placed into another <TMPL_VAR>. What you probably want is a <TMPL_INCLUDE>. 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 <TMPL_VAR>. |
From: LDT <per...@ya...> - 2004-01-08 22:14:19
|
I'm running into an error when trying to pass a TMPL_VAR inside a TMPL_VAR and have it be evaluated. I've set global_vars = 1, so I was thinking that would help. I've included the pieces of my program, template and output. As you can see, most of the TMP_VARs are evaluated/passed, but the internal TMPL_VAR isn't (although it's also the same "bgcolor" variable used in the <tr> line, which I highlighted in bold below. Am I missing something, or am I trying to do something naughty? Within my main program: #set up format parameter for data cells in summary report 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 ; #Pass parameters to template; print report $tmpl_main->param( cell_fmt => $cell_fmt, passdata => \@loop_data); print $tmpl_main->output(); Within my template: <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> The relevant section of the results when I view the source of the page (after the "invalid argument" errors): <tr class=normal bgcolor=#FFFFFF> <td align="right" style="cursor:pointer;cursor:hand;" title="Click to drill down" onmouseover="style.background='#CCCCFF';" onmouseout ="style.background='<TMPL_VAR NAME=bgcolor>';"> <font color=#000000>$12,345.67</td> --------------------------------- Do you Yahoo!? Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes |
From: Timm M. <tm...@ag...> - 2004-01-07 20:15:56
|
At 02:20 PM 1/7/04 -0500, Todd Chapman wrote: >Using the method described below, do I have to set >the params in the appropriate teamplates, or can I >do the include first and set all the params in one >template? The reason I ask is that the params all >come from one database table, and I don't want >to worry about which template has which TMPL_VARs. The main template would get the data that was in the included template when you called output() on the included one. |
From: Todd C. <htm...@ch...> - 2004-01-07 20:15:43
|
If TMPL_INCLUDE is processed first, does that mean I can't do this? (Using HTML::Template::Expr) <TMPL_IF EXPR="include_param = 'x'"> <TMPL_INCLUDE NAME="<TMPL_VAR NAME=x>" </TMPL_IF> On Wed, Jan 07, 2004 at 02:48:35PM -0500, Jason Purdy wrote: > My guess is that it's trying to do the INCLUDE *BEFORE* doing the > variable substitution. > > So if you're stuck on making the included file dynamic, I would > recommend a two-sweep approach, which I see Timm Murray's post addresses. > > Cheers, > > Jason > > Todd Chapman wrote: > > >I would like to pass a parameter to a template that > >would be used to include another template. This > >syntax does not seem to be valid: > > > > <TMPL_INCLUDE NAME="<TMPL_VAR NAME=include_param>"> > > > >How can I accomplish this? > > > >Thanks. > > > >-Todd > > > > > > > >------------------------------------------------------- > >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 > >Htm...@li... > >https://lists.sourceforge.net/lists/listinfo/html-template-users |
From: Todd C. <htm...@ch...> - 2004-01-07 20:12:31
|
Using the method described below, do I have to set the params in the appropriate teamplates, or can I do the include first and set all the params in one template? The reason I ask is that the params all come from one database table, and I don't want to worry about which template has which TMPL_VARs. Thanks. -Todd On Wed, Jan 07, 2004 at 01:26:19PM -0600, Timm Murray wrote: > At 01:24 PM 1/7/04 -0500, Todd Chapman wrote: > >I would like to pass a parameter to a template that > >would be used to include another template. This > >syntax does not seem to be valid: > > > > <TMPL_INCLUDE NAME="<TMPL_VAR NAME=include_param>"> > > > >How can I accomplish this? > <> > > I use the output from one template to feed into another: > > ---- > my $tmpl1 = HTML::Template->new( . . . ); > my $tmpl2 = HTML::Template->new( . . . ); > # Bunch of params() calls here > $tmpl2->param( included => $tmpl1->output() ); > print $tmpl1->output(); > ---- > > With a <TMPL_VAR included> in $tmpl2's file. |
From: Jason P. <ja...@jo...> - 2004-01-07 19:49:12
|
My guess is that it's trying to do the INCLUDE *BEFORE* doing the variable substitution. So if you're stuck on making the included file dynamic, I would recommend a two-sweep approach, which I see Timm Murray's post addresses. Cheers, Jason Todd Chapman wrote: > I would like to pass a parameter to a template that > would be used to include another template. This > syntax does not seem to be valid: > > <TMPL_INCLUDE NAME="<TMPL_VAR NAME=include_param>"> > > How can I accomplish this? > > Thanks. > > -Todd > > > > ------------------------------------------------------- > 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 > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users |