html-template-users Mailing List for HTML::Template (Page 12)
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: Karen <kar...@gm...> - 2007-04-30 02:12:08
|
On 4/29/07, Dan Horne <dan...@re...> wrote: > Well, I'm not "so" concerned (which to me implies some kind of fervour > that I don't think I stated). I was simply asking if there was a way to > iterate through integer values that I couldn't see in the POD - simple > so the designers could decide what to do with the integer - either > iterate from 1 to it, or print it out. Doing it in Perl tends to pre- > suppose one solution over the other. The designers don't really have > problems with loops - they've used H:T and TT, but I don't think they > want to learn Javascript. Plus, even if you use JS you haven't solved the problem for the people who don't use JS. (Of which I'm sometimes one.) If you do give them a loop, they can at least decide whether to iterate it fully, or to use only the "__last__" value and print it. So there's that. (Not bad for a four- or five-star scale, though it tends to break down in my case, where I've got threads that nest out to a couple hundred levels... there's just no simple solution there.) |
From: Dan H. <dan...@re...> - 2007-04-30 00:59:48
|
On Sun, 2007-04-29 at 20:34 -0400, Michael Peters wrote: > Dan Horne wrote: > > Hi all > > > > Is there a way to loop from a lower integer to an higher one? For example, > > say an article has a rating of 4. I'd like to loop from 1 to 4 and print a > > star at each iteration. The only way I can see of doing this is create an > > array ref in the perl coder and pass that to the template, which seems a lot > > of pointless effort > > If you're so concerned about doing it in your Perl code, then I'd do it with > Javascript. Create extra image elements depending on the rating value. > Well, I'm not "so" concerned (which to me implies some kind of fervour that I don't think I stated). I was simply asking if there was a way to iterate through integer values that I couldn't see in the POD - simple so the designers could decide what to do with the integer - either iterate from 1 to it, or print it out. Doing it in Perl tends to pre- suppose one solution over the other. The designers don't really have problems with loops - they've used H:T and TT, but I don't think they want to learn Javascript. Thanks Dan |
From: Dan H. <dan...@re...> - 2007-04-30 00:55:41
|
On Mon, 2007-04-30 at 10:40 +1000, Mathew Robertson wrote: > > > > > Is there a way to loop from a lower integer to an higher > > one? For example, > > say an article has a rating of 4. I'd like to loop from 1 to > > 4 and print a > > star at each iteration. The only way I can see of doing this > > is create an > > array ref in the perl coder and pass that to the template, > > which seems a lot > > of pointless effort > > > > > > I've been trying to think of a way to do that with CSS, since > > currently I'd like to indent things based on a "level" variable > > passed through the template (and to complicate things, I'd like to > > max out at a certain point to avoid right-margin squish, considering > > that in a couple of cases the threads nest over two hundred levels > > deep). > > > > With (one assumes) a rating system with its own ceiling, though, you > > could go with img src="blahblah/star<TMPL_VAR name="rating">.gif" or > > what have you, and just have a set of graphics with star1.gif having > > one star, star2.gif having two stars, and so forth. > > > If you just want to print 4 stars, then just do that. * * * * > > If you are looking for some indentation background, you could try > something like the following on a div: > > style="background:url('star.gif') right repeat-y;" > > If you are looking for something like <TMPL_FOR 1..4> then you > probably need to re-evaluate why you need it - maybe you need to re- > think your original problem. That said, there have been previous > discussions on whether the TMPL_xxx syntax should support user-defined > extensions, and various people have their own hacks to allow such a > feature (which would then allow you to build your TMPL_FOR). Well my problem is that sometimes I want to iterate through a numeric range. If an article is ranked 4 stars then the designer can either iterate through each ranking and display a star or he/she can simply output "4 stars." (one customer likes the latter, another wants the former). Likewise, I use Data::Page::Navigation for paginated data - it's a really nice module, and if it displays 10 indexes at the bottom of the page, say from 5 - 14, it would be nice if I could iterate through them rather than doing it in Perl. It's not a religious decision, it just gives the flexibility to the designers. > What is the problem you are trying to solve? Someone here might have > solved it already... I hope this gives enough info. If I'm doing it wrong, I'm only too pleased to be told if there's a better way. Michael Peters suggested Javascript as one solution, although I'd prefer a solution in H::T if possible. I have looked through the docs, and couldn't see anything obvious, but was hoping that perhaps someone had solved this problem before me via some kind of logic that I hadn't thought of. > > Mathew Dan |
From: Mathew R. <mat...@ne...> - 2007-04-30 00:40:16
|
> > Is there a way to loop from a lower integer to an higher one? For > example, > say an article has a rating of 4. I'd like to loop from 1 to 4 and > print a > star at each iteration. The only way I can see of doing this is > create an > array ref in the perl coder and pass that to the template, which > seems a lot > of pointless effort > > > I've been trying to think of a way to do that with CSS, since > currently I'd like to indent things based on a "level" variable passed > through the template (and to complicate things, I'd like to max out at > a certain point to avoid right-margin squish, considering that in a > couple of cases the threads nest over two hundred levels deep). > > With (one assumes) a rating system with its own ceiling, though, you > could go with img src="blahblah/star<TMPL_VAR name="rating">.gif" or > what have you, and just have a set of graphics with star1.gif having > one star, star2.gif having two stars, and so forth. > If you just want to print 4 stars, then just do that. * * * * If you are looking for some indentation background, you could try something like the following on a div: style="background:url('star.gif') right repeat-y;" If you are looking for something like <TMPL_FOR 1..4> then you probably need to re-evaluate why you need it - maybe you need to re-think your original problem. That said, there have been previous discussions on whether the TMPL_xxx syntax should support user-defined extensions, and various people have their own hacks to allow such a feature (which would then allow you to build your TMPL_FOR). What is the problem you are trying to solve? Someone here might have solved it already... Mathew |
From: Dan H. <dan...@re...> - 2007-04-30 00:36:05
|
On Sun, 2007-04-29 at 19:22 -0500, Karen wrote: > On 4/29/07, Dan Horne <dan...@re...> wrote: > > Is there a way to loop from a lower integer to an higher one? > For example, > say an article has a rating of 4. I'd like to loop from 1 to 4 > and print a > star at each iteration. The only way I can see of doing this > is create an > array ref in the perl coder and pass that to the template, > which seems a lot > of pointless effort > > > With (one assumes) a rating system with its own ceiling, though, you > could go with img src="blahblah/star<TMPL_VAR name="rating">.gif" or > what have you, and just have a set of graphics with star1.gif having > one star, star2.gif having two stars, and so forth. That would work. It's a shame that there isn't a regular loop construct, as I'd like a solution for all sorts of loop instances (Looping through the pagination indexes generated by Data::Page::Navigation for instance) Dan |
From: Michael P. <mp...@pl...> - 2007-04-30 00:35:15
|
Dan Horne wrote: > Hi all > > Is there a way to loop from a lower integer to an higher one? For example, > say an article has a rating of 4. I'd like to loop from 1 to 4 and print a > star at each iteration. The only way I can see of doing this is create an > array ref in the perl coder and pass that to the template, which seems a lot > of pointless effort If you're so concerned about doing it in your Perl code, then I'd do it with Javascript. Create extra image elements depending on the rating value. -- Michael Peters Developer Plus Three, LP |
From: Karen <kar...@gm...> - 2007-04-30 00:22:15
|
On 4/29/07, Dan Horne <dan...@re...> wrote: > Is there a way to loop from a lower integer to an higher one? For example, > say an article has a rating of 4. I'd like to loop from 1 to 4 and print a > star at each iteration. The only way I can see of doing this is create an > array ref in the perl coder and pass that to the template, which seems a > lot > of pointless effort I've been trying to think of a way to do that with CSS, since currently I'd like to indent things based on a "level" variable passed through the template (and to complicate things, I'd like to max out at a certain point to avoid right-margin squish, considering that in a couple of cases the threads nest over two hundred levels deep). With (one assumes) a rating system with its own ceiling, though, you could go with img src="blahblah/star<TMPL_VAR name="rating">.gif" or what have you, and just have a set of graphics with star1.gif having one star, star2.gif having two stars, and so forth. |
From: Dan H. <dan...@re...> - 2007-04-30 00:10:59
|
Hi all Is there a way to loop from a lower integer to an higher one? For example, say an article has a rating of 4. I'd like to loop from 1 to 4 and print a star at each iteration. The only way I can see of doing this is create an array ref in the perl coder and pass that to the template, which seems a lot of pointless effort Regards Dan |
From: Sven N. <sve...@sv...> - 2007-04-25 11:55:09
|
Robert Franks wrote: > It seems the page does not invoke the call to 'urchin.js' as am getting > javascript error: > 'urchintracker() not defined' I checked: The function name is "urchinTracker", JavaScript is case sensitive. -Sven |
From: Robert F. <so...@to...> - 2007-04-25 11:40:20
|
Using HTML::Template Have placed the Google Analytics code: <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> </script> <script type="text/javascript"> _uacct = "UA-xxxxxx-1"; urchintracker(); </script> at the end of my template page just before closing body tag.. It seems the page does not invoke the call to 'urchin.js' as am getting javascript error: 'urchintracker() not defined' Is this because the cgi script is loading the page and is therefore having trouble invoking the javascript? -- Robert Franks |
From: Barry M. <bmi...@th...> - 2007-04-16 22:57:58
|
That was it! Knew it was simple, but couldn't see it. Thanks! Sam Tregar wrote: > On Mon, 16 Apr 2007, Barry Michels wrote: > >> my $pjx = new CGI::Ajax('change_page' => \&change_page); > > I'm guess that CGI::Ajax is expecting you to return the HTML, not > print it. So try changing this: > > print Show_Content($pg) if(defined $pg); > > To: > > return Show_Content($pg) if(defined $pg); > > When you put a print() as the last statement in a subroutine it will > return 1 when it succeeds. > > -sam |
From: Karen <kar...@gm...> - 2007-04-16 22:43:35
|
On 4/16/07, Barry Michels <bmi...@th...> wrote: > > print $pjx->build_html($cgi,\&Show_HTML); This is going to print the result of the build_html... a nice successful 1, it appears. You might want to test the result, but you probably don't want to print anything on success. > sub change_page { > my $pg = $cgi->param('page'); > print Show_Content($pg) if(defined $pg); > } This is what prints the actual page. |
From: Sam T. <sa...@tr...> - 2007-04-16 22:38:13
|
On Mon, 16 Apr 2007, Barry Michels wrote: > my $pjx = new CGI::Ajax('change_page' => \&change_page); I'm guess that CGI::Ajax is expecting you to return the HTML, not print it. So try changing this: print Show_Content($pg) if(defined $pg); To: return Show_Content($pg) if(defined $pg); When you put a print() as the last statement in a subroutine it will return 1 when it succeeds. -sam |
From: Barry M. <bmi...@th...> - 2007-04-16 21:49:56
|
You're right, that's not the exact code. I'm using CGI:Ajax in addition to HTML::Template. At first, I was using strictly CGI:Ajax and doing a $template->output; directly at the end of each sub. But, I wanted to be able to work with users that don't have JavaScript enabled or portable devices that don't support JS. Now, I return the $template->output and either print it (for AJAX) or assign it to a tmpl_var in the whole page template. Putting it into the page template as a TMPL_VAR doesn't show the 1. Only printing it after an AJAX call. It does happen with this code (stripped down version of my full script to save bandwidth): #!/usr/bin/perl -w use strict; use CGI; use CGI::Ajax; use HTML::Template; my $cgi = new CGI(); my $pjx = new CGI::Ajax('change_page' => \&change_page); print $pjx->build_html($cgi,\&Show_HTML); sub change_page { my $pg = $cgi->param('page'); print Show_Content($pg) if(defined $pg); } sub Show_HTML { my $template = HTML::Template->new(filename => "/var/www/localhost/htdocs/perlsite/index.tmpl"); my $content = ''; my $content_template = HTML::Template->new(filename => "/var/www/localhost/htdocs/perlsite/content/index.html"); $content = $content_template->output; $template->param(content => $content); return $template->output; } sub Show_Content { my $pg = shift; my $template = HTML::Template->new(filename => "/var/www/localhost/htdocs/perlsite/content/$pg.html") return $template->output; } |
From: Sam T. <sa...@tr...> - 2007-04-16 21:16:49
|
On Mon, 16 Apr 2007, Barry Michels wrote: > This probably has a very simple solution. I am returning > $template->output from a sub and then printing the results. Every time, > there's a trailing '1' at the end of the data. How do I eliminate it? That 1 is likely the return value from print(). I don't know how it's getting printed, but I suspect the code you posted isn't the code you're running. I tried it and I didn't get a trailing one. Are you using CGI::Application perhaps? -sam |
From: Barry M. <bmi...@th...> - 2007-04-16 19:28:01
|
This probably has a very simple solution. I am returning $template->output from a sub and then printing the results. Every time, there's a trailing '1' at the end of the data. How do I eliminate it? index.tmpl: <html> <head> <title>Hello</title> </head> <body> Hello World! </body> </html> print Show_HTML(); sub Show_HTML { my $template = HTML::Template->new(filename => 'index.tmpl'); return $template->output; } Result: Hello World!1 |
From: Greg J. <gr...@al...> - 2007-04-13 03:57:06
|
On Thursday April 12 2007 4:53 pm, Dan Horne wrote: > Hi > > Have a look at the CGI::Ajax demo code for "Skips using build_html()" > http://www.perljax.us/demo/pjx_nobuild.txt > > As with the example you'll need to include > > <div id=3D'__pjxrequest'></div> > > in your template. Since your html is in a template you can ignore the > example's "hard-coded" HTML, and simply make sure that you have the > following H::T tag in your HTML <head> section: > > <tmpl_var pjx> > > Set the tag in your Perl code with > > $template->param('pjx' =3D> $pjx); > > Sorry I don't have any concise examples since I use CGI::Ajax with > CGI::Application and there's a lot of irrelevant stuff, but this should > work for you > > Dan > > > -----Original Message----- > > From: htm...@li... > > [mailto:htm...@li...] On > > Behalf Of Greg Jetter > > Sent: Friday, 13 April 2007 12:30 p.m. > > To: htm...@li... > > Subject: [htmltmpl] using HTML::Template with CGI:Ajax > > > > HI folks: > > > > =A0=A0=A0=A0=A0=A0=A0=A0I'm trying to figure out how to use =A0the two = =A0modules > > together , I've been using HTML::Template for a wile now =A0and > > and commfy using it , I want to start using =A0the =A0CGI::Ajax > > module =A0and am looking for =A0examples or advice on how to call > > my template file =A0and have it work with the other. From what > > I understand , =A0the CGI::Ajax object is supposed to =A0write > > stuff to the header of the returned =A0html code passed to it. > > > > anybody ever use these two together ? > > > > I'm thinking that the cgi-ajax method =A0build_html is what I > > need =A0and maybe pass it =A0tmpl->output ? > > > > > > I haven't even =A0written =A0any code yet , still researching , > > Google dose not > > give me much to work with so I'm trying here. > > > > Just would like to see a simple example of =A0using HTML::Template with > > =A0CGI::Ajax . > > > > > > > > > > Thanks > > > > Greg Jetter > > > > -------------------------------------------------------------- > > ----------- > > Take Surveys. Earn Cash. Influence the Future of IT > > Join SourceForge.net's Techsay panel and you'll get the > > chance to share your > > opinions on IT & business topics through brief surveys-and earn cash > > http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge > > &CID=3DDEVDEV > > > _______________________________________________ > > Html-template-users mailing list > > Htm...@li... > > https://lists.sourceforge.net/lists/listinfo/html-template-users > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share > your opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D= DEVDEV > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users thanks Dan , that helps a lot Greg |
From: Dan H. <dan...@re...> - 2007-04-13 00:53:03
|
Hi Have a look at the CGI::Ajax demo code for "Skips using build_html()" http://www.perljax.us/demo/pjx_nobuild.txt As with the example you'll need to include <div id=3D'__pjxrequest'></div> in your template. Since your html is in a template you can ignore the example's "hard-coded" HTML, and simply make sure that you have the following H::T tag in your HTML <head> section: <tmpl_var pjx>=20 Set the tag in your Perl code with $template->param('pjx' =3D> $pjx);=20 Sorry I don't have any concise examples since I use CGI::Ajax with CGI::Application and there's a lot of irrelevant stuff, but this should = work for you Dan > -----Original Message----- > From: htm...@li...=20 > [mailto:htm...@li...] On=20 > Behalf Of Greg Jetter > Sent: Friday, 13 April 2007 12:30 p.m. > To: htm...@li... > Subject: [htmltmpl] using HTML::Template with CGI:Ajax >=20 > HI folks: >=20 > =A0=A0=A0=A0=A0=A0=A0=A0I'm trying to figure out how to use =A0the two = =A0modules=20 > together , I've been using HTML::Template for a wile now =A0and=20 > and commfy using it , I want to start using =A0the =A0CGI::Ajax=20 > module =A0and am looking for =A0examples or advice on how to call=20 > my template file =A0and have it work with the other. From what=20 > I understand , =A0the CGI::Ajax object is supposed to =A0write=20 > stuff to the header of the returned =A0html code passed to it. >=20 > anybody ever use these two together ?=20 >=20 > I'm thinking that the cgi-ajax method =A0build_html is what I=20 > need =A0and maybe pass it =A0tmpl->output ? >=20 >=20 > I haven't even =A0written =A0any code yet , still researching ,=20 > Google dose not=20 > give me much to work with so I'm trying here. >=20 > Just would like to see a simple example of =A0using HTML::Template = with=20 > =A0CGI::Ajax .=20 >=20 >=20 >=20 >=20 > Thanks=20 >=20 > Greg Jetter >=20 > -------------------------------------------------------------- > ----------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the=20 > chance to share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge &CID=3DDEVDEV > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users >=20 |
From: Greg J. <gr...@al...> - 2007-04-13 00:31:11
|
HI folks: =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0I'm trying to figure out ho= w to use =C2=A0the two =C2=A0modules together , I've=20 been=20 using HTML::Template for a wile now =C2=A0and and commfy using it , I want = to=20 start using =C2=A0the =C2=A0CGI::Ajax module =C2=A0and am looking for =C2= =A0examples or advice on=20 how to call my template file =C2=A0and have it work with the other. From wh= at I=20 understand , =C2=A0the CGI::Ajax object is supposed to =C2=A0write stuff to= the header=20 of the returned =C2=A0html code passed to it. anybody ever use these two together ?=20 I'm thinking that the cgi-ajax method =C2=A0build_html is what I need =C2= =A0and maybe=20 pass it =C2=A0tmpl->output ? I haven't even =C2=A0written =C2=A0any code yet , still researching , Googl= e dose not=20 give me much to work with so I'm trying here. Just would like to see a simple example of =C2=A0using HTML::Template with= =20 =C2=A0CGI::Ajax .=20 Thanks=20 Greg Jetter |
From: Robert H. <si...@gm...> - 2007-04-12 13:04:00
|
I would be curious on how many HT'ers using the dot plugin and what they think of it as well. |
From: Sanjeet G. <sg...@gm...> - 2007-04-11 02:29:09
|
Hello all, I am not a very experienced perl programmer and I do not have access to the server or fancy modperl. Thus, I needed something that I could drop in and TT kept giving me errors when I tried that. HTML::Template was the only one that worked for me. I found the dot plugin on CPAN and began using it as I need hash support currently not offered in the regular distribution. The package description said that no attempt to benchmark has been done. My question is how much slower is this plugin over the regular distribution (even anecdotal evidence helps). Prior to HT, I generally used the qq~ ~; in subroutines and I would call the subroutine if I wanted to use that particular html code section. After switching to HT, my primitive benchmarking system showed a 0.07s increase in execution time from ~0.15 to ~0.22. I really like the system and my code is a lot cleaner now. I tried the file cache system but I saw no reduction in execution time (does this help w/ server load instead?). The temp files are being generated so it must be working correctly. I apologize for my newbie questions ahead of time. Any advice/help is much appreciated. Thank you, Sanjeet Ganjam Email: sg...@gm... |
From: David K. <da...@gi...> - 2007-04-10 23:22:33
|
Hi Tim, Tim Walters <twa...@so...> wrote: > We've discovered a problem... [and sent a patch and a test] Nice catch! > It would be great if this could be folded into the official > distribution. Finding and fixing *and* writing the test... I'm guessing your contribution will be welcomed! -dave |
From: Tim W. <twa...@so...> - 2007-04-10 23:00:24
|
Greetings, We've discovered a problem with the handling of simple expressions in HTML::Template::Expr 0.07. Briefly, if a variable "foo" is defined, an expression with just the variable name will fail. For example, both of these tags fail: <tmpl_var expr="foo"> <tmpl_if expr="foo">Yes</tmpl_if> This used to work in version 0.04. We have a workaround in that we can convert to using a name attribute, i.e., <tmpl_var name="foo"> but we have a lot of templates and would like not to modify them. I looked a little closer at Expr.pm and found a bug in the discovery of variable names with no operators. The analysis always starts at the second level of the parse tree. The enclosed one line patch just wraps the test parse tree in an array while testing so that discovery will bare name variables. All unit tests pass after applying this. I've also enclosed a simple test case and template file to demonstrate this bug. It would be great if this could be folded into the official distribution. Let me know if you need any additional information about this. Thanks, Tim Walters --- Expr.pm~ 2007-02-14 22:36:11.000000000 -0800 +++ Expr.pm 2007-02-15 22:37:28.000000000 -0800 @@ -197,7 +197,7 @@ my %vars; # hunt for VAR nodes in the tree - my @stack = @$tree; + my @stack = ($tree); while (@stack) { my $node = shift @stack; if (ref $node and ref $node eq 'ARRAY') { --- /dev/null 2007-04-10 15:50:33.000000000 -0700 +++ t/50exprname.t 2007-02-15 15:27:26.000000000 -0800 @@ -0,0 +1,10 @@ +use Test::More tests => 2; +use HTML::Template::Expr; + +$template = HTML::Template::Expr->new(die_on_bad_params => 0, + path => ['t/templates'], + filename => 'nameexpr.tmpl'); +$template->param(foo => 100); +$output = $template->output(); +like($output, qr/100/, "<TMPL_VAR EXPR=\"name\"> works"); +like($output, qr/Yes/, "<TMPL_IF EXPR=\"name\"> works"); --- /dev/null 2007-04-10 15:55:27.000000000 -0700 +++ t/templates/nameexpr.tmpl 2007-02-15 15:24:58.000000000 -0800 @@ -0,0 +1,2 @@ +<tmpl_var expr="foo"> +<tmpl_if expr="foo">Yes</tmpl_if> |
From: Mathew R. <mat...@ne...> - 2007-04-03 23:01:05
|
Hi Jason, Are you simply looking for something like TMPL_INCLUDE ? Mathew Jason Purdy wrote: > Thanks for the thoughts! > > I'm not sure I understand what you're saying here. If you're saying > you can just use nested TMPL_VARs, then I think you may be missing my > point. Your code: > > > my $ht = new H::T(filename => "helloworld.tmpl"); > # Don't forget you need to also put together $ht's parameters > > my $helloworld = $ht->output(); > > $ht = new H::T(filename => "index.tmpl"); > > $ht->param("helloworld" => $helloworld); > > $ht->output(); > > Whereas if you had something like TMPL_VIRTUAL, you could eliminate > the first 3 lines (or more) of code since the index.tmpl would have a > TMPL_VIRTUAL to point to a cgi script that put together the output of > helloworld.tmpl. > > Hmm - I think I may have just realized what you were talking about, > but this whole feature wouldn't be useful for including nested > templates, but rather the output from a URL (i.e. a cgi script, php > page, etc) > > Sorry for the rambling ... this whole email may not make sense ... > haven't digested my coffee yet! ;) > > - Jason > > > Mathew Robertson wrote: >> Hi Jason, >> >> I personally think this is a good idea, especially if it was provided >> by a plugin (which means other TMPL_xxx's would also be possible). >> >> >> In this case probably what you want is to use a TMPL_VAR which >> contains the output of a seperate H::T instance, as in: >> >> my $ht = new H::T(filename => "helloworld.tmpl"); >> my $helloworld = $ht->output(); >> $ht = new H::T(filename => "index.tmpl"); >> $ht->param("helloworld" => $helloworld); >> $ht->output(); >> >> or something like that, ie: generate your virtual's before generating >> your output. >> >> Mathew >> >> >> Jason Purdy wrote: >>> How about a new tag, either as part of the standard distribution or >>> a plugin: >>> >>> TMPL_VIRTUAL >>> >>> The one thing that I like when I'm doing PHP pages is that I can >>> build singular dynamic components and simply include them from the >>> parent template. >>> >>> i.e. >>> >>> # FILE: index.php >>> <? virtual( 'helloworld.php' ); ?> >>> >>> >>> # FILE: helloworld.php >>> <? print "Hello World!"; ?> >>> >>> Yes, I know about Philipp's Widgets articles[1] on perl.com, but you >>> still need to put the encapsulation logic in your code, which seems >>> redundant. >>> >>> How about if the HTML_VIRTUAL called LWP to request the URL and >>> replace the tag w/ the response's content? >>> >>> # FILE: index.TMPL >>> <!-- TMPL_VIRTUAL URL="helloworld.php" --> >>> >>> # FILE: helloworld.php >>> <? print "Hello World!"; ?> >>> >>> - Jason >>> >>> [1]: http://www.perl.com/pub/a/2007/02/02/htmltemplate-widgets.html >>> >>> ------------------------------------------------------------------------- >>> >>> Take Surveys. Earn Cash. Influence the Future of IT >>> Join SourceForge.net's Techsay panel and you'll get the chance to >>> share your >>> opinions on IT & business topics through brief surveys-and earn cash >>> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV >>> >>> _______________________________________________ >>> Html-template-users mailing list >>> Htm...@li... >>> https://lists.sourceforge.net/lists/listinfo/html-template-users >>> |
From: Mathew R. <mat...@ne...> - 2007-04-03 05:27:30
|
Hi Jason, I personally think this is a good idea, especially if it was provided by a plugin (which means other TMPL_xxx's would also be possible). In this case probably what you want is to use a TMPL_VAR which contains the output of a seperate H::T instance, as in: my $ht = new H::T(filename => "helloworld.tmpl"); my $helloworld = $ht->output(); $ht = new H::T(filename => "index.tmpl"); $ht->param("helloworld" => $helloworld); $ht->output(); or something like that, ie: generate your virtual's before generating your output. Mathew Jason Purdy wrote: > How about a new tag, either as part of the standard distribution or a > plugin: > > TMPL_VIRTUAL > > The one thing that I like when I'm doing PHP pages is that I can build > singular dynamic components and simply include them from the parent > template. > > i.e. > > # FILE: index.php > <? virtual( 'helloworld.php' ); ?> > > > # FILE: helloworld.php > <? print "Hello World!"; ?> > > Yes, I know about Philipp's Widgets articles[1] on perl.com, but you > still need to put the encapsulation logic in your code, which seems > redundant. > > How about if the HTML_VIRTUAL called LWP to request the URL and replace > the tag w/ the response's content? > > # FILE: index.TMPL > <!-- TMPL_VIRTUAL URL="helloworld.php" --> > > # FILE: helloworld.php > <? print "Hello World!"; ?> > > - Jason > > [1]: http://www.perl.com/pub/a/2007/02/02/htmltemplate-widgets.html > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users > |