html-template-users Mailing List for HTML::Template (Page 26)
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: Webmaster Techcode.N. <web...@te...> - 2005-11-08 23:53:47
|
MessageNo need to send emails to both me and list (twice) I guess ? Anyway - I already looked into that. It's what = CGI::Application::Framework uses. But it's not what I need/want. That way I can only call some run_mode (method) from current module (one = that is outputing the template in the first place). I would need to manualy add plugins = to each of the module (or just in base module).=20 On the other hand, I could write an method in my base module (inherited = by others). And implement that logic inside of him (require SomeModule, call some_run_mode in it = ...). But all that would be similar like this: <TMPL_VAR = NAME=3D"CGIAPP_EMBED('run_plugin','some_plugin','param1','param')"> I was hopping to avoid that ... and make it shorter/simpler as: <TMPL_PLUGIN NAME=3D"SomeName(param1, param2)"> ----- Original Message -----=20 From: Dan Horne=20 To: 'Webmaster Techcode.NET' ; = htm...@li...=20 Sent: Tuesday, November 08, 2005 11:33 PM Subject: RE: [htmltmpl] Writing an extension for HTML::Template - how = to do it? Hi Since you're using CGI::App, you should have a look at = CGI::Application::Plugin::AnyTemplate - which will allow you to call a = run mode with the H::T <TMPL_VAR NAME=3D"CGIAPP_embed('some_run_mode', 'param, 'param')"> Dan -----Original Message----- From: htm...@li... = [mailto:htm...@li...] On Behalf Of = Webmaster Techcode.NET Sent: Wednesday, 9 November 2005 11:16 To: htm...@li... Subject: [htmltmpl] Writing an extension for HTML::Template - how to = do it? Hello folks! Don't know if it's just me or documentation of = HTML::Template::Extension isn't good. Eitherway, I can't figure out how = to write an extenstion for it, that I need for my project.=20 I work with CGI::Application, and I wan't to be able to use = (reusable) objects in my templates. For instance : <tmpl_plugin name=3D"SomeName(param1, param2)"> My filter would find SomeName module (Prefix such as = MyApp::Plugin::SomeName) make an instance of it and call method - say = named run. And place returned value instead of this tag. Think of it as another template file that is included but it has = some processing ... That way I can create one module/plugin and use it = througth whole site/application. If I don't figure this out soon - I will have to give a shot to = HTML::Template::Expr and register a function with it (<tmpl_var = name=3D"plugin(SomeName, param1, param2)">). Thanks. |
From: Dan H. <dan...@re...> - 2005-11-08 22:33:30
|
Hi =20 Since you're using CGI::App, you should have a look at CGI::Application::Plugin::AnyTemplate - which will allow you to call a = run mode with the H::T =20 <TMPL_VAR NAME=3D"CGIAPP_embed('some_run_mode', 'param, 'param')"> =20 Dan =20 -----Original Message----- From: htm...@li... [mailto:htm...@li...] On Behalf Of Webmaster Techcode.NET Sent: Wednesday, 9 November 2005 11:16 To: htm...@li... Subject: [htmltmpl] Writing an extension for HTML::Template - how to do = it? Hello folks! =20 Don't know if it's just me or documentation of HTML::Template::Extension isn't good. Eitherway, I can't figure out how to write an extenstion for = it, that I need for my project.=20 =20 I work with CGI::Application, and I wan't to be able to use (reusable) objects in my templates. =20 For instance : =20 <tmpl_plugin name=3D"SomeName(param1, param2)"> =20 My filter would find SomeName module (Prefix such as MyApp::Plugin::SomeName) make an instance of it and call method - say = named run. And place returned value instead of this tag. =20 Think of it as another template file that is included but it has some processing ... That way I can create one module/plugin and use it = througth whole site/application. =20 =20 If I don't figure this out soon - I will have to give a shot to HTML::Template::Expr and register a function with it (<tmpl_var name=3D"plugin(SomeName, param1, param2)">). =20 Thanks. =20 |
From: Webmaster Techcode.N. <web...@te...> - 2005-11-08 22:17:44
|
Hello folks! Don't know if it's just me or documentation of HTML::Template::Extension = isn't good. Eitherway, I can't figure out how to write an extenstion for = it, that I need for my project.=20 I work with CGI::Application, and I wan't to be able to use (reusable) = objects in my templates. For instance : <tmpl_plugin name=3D"SomeName(param1, param2)"> My filter would find SomeName module (Prefix such as = MyApp::Plugin::SomeName) make an instance of it and call method - say = named run. And place returned value instead of this tag. Think of it as another template file that is included but it has some = processing ... That way I can create one module/plugin and use it = througth whole site/application. If I don't figure this out soon - I will have to give a shot to = HTML::Template::Expr and register a function with it (<tmpl_var = name=3D"plugin(SomeName, param1, param2)">). Thanks. |
From: Carl F. <fir...@gm...> - 2005-11-07 12:10:19
|
On 07/11/05, Rakhi Verma <rak...@fl...> wrote: > > Hi, > I am facing some problem with the output of TMPL_VAR VALUE when > the VALUE text contains space charater e.g "abc efg". > When the template is output the <TMPL_VAR> is not replaced with the VALU= E > text i have specified. > Only the value before the space i.e "abc" is displayed. > > > "test.tmpl" file contains this line: > > <input maxlength=3D"50" name=3D"name" value=3D<TMPL_VAR NAME=3Dcust_name> > > > "test.pl" script contains this code: > > my $template =3D HTML::Template->new(filename =3D> test.tmpl); > $template->param(cust_name =3D> "Deepak Puri"); > > my $value =3D $template->param('cust_name'); > > > $value contains "Deepak Puri". But when html is displayed only "deepak" i= s > displayed . > String after the space character is not displayed. > > Can you please provide a solution to this ASAP. Your HTML is to blame. If you have a space in the value, then you should surround the value with quotes in the HTML. value=3D"<TMPL_VAR NAME=3Dcust_name>" Carl |
From: Rakhi V. <rak...@fl...> - 2005-11-07 11:58:20
|
Hi, I am facing some problem with the output of TMPL_VAR VALUE when the VALUE text contains space charater e.g "abc efg". When the template is output the <TMPL_VAR> is not replaced with the VALUE text i have specified. Only the value before the space i.e "abc" is displayed. "test.tmpl" file contains this line: <input maxlength="50" name="name" value=<TMPL_VAR NAME=cust_name> "test.pl" script contains this code: my $template = HTML::Template->new(filename => test.tmpl); $template->param(cust_name => "Deepak Puri"); my $value = $template->param('cust_name'); $value contains "Deepak Puri". But when html is displayed only "deepak" is displayed . String after the space character is not displayed. Can you please provide a solution to this ASAP. Thanks & regards Rakhi *********************** FSS-Private *********************** "DISCLAIMER: This message is proprietary to Flextronics Software Systems Limited (FSS) and is intended solely for the use of the individual to whom it is addressed. It may contain privileged or confidential information and should not be circulated or used for any purpose other than for what it is intended. If you have received this message in error, please notify the originator immediately. If you are not the intended recipient, you are notified that you are strictly prohibited from using, copying, altering, or disclosing the contents of this message. FSS accepts no responsibility for loss or damage arising from the use of the information transmitted by this email including damage from virus." |
From: Carl F. <fir...@gm...> - 2005-11-04 14:09:55
|
You can't change a tempate according the the_value_ of a variable, however you could change your hash structure from hash1=3D>{ type =3D>"text", ... }, hash2=3D>{ type=3D>"dropdown", ... } To something more like hash1=3D>{ text =3D> 1, ... }, hash2=3D>{ dropdown =3D> 1, ... } And then in the template something like <TMPL_IF text> ... </TMPL_IF> <TMPL_IF dropdown> ... </TMPL_IF> Carl |
From: srinivasan v. <sri...@ya...> - 2005-11-04 13:26:07
|
hi, i need to define html::template from the following hash. %add=( hash1=>{ name=>"name1 ", type =>"text", default=>" " value=[""], entries=>"M". }, hash2=>{ name=>"name2 ", type=>"dropdown", req=>"prc", default=>" " value=["value1","value2","value3"], entries=>" " } ); I need to define text box if the type is text ie if type=>"text",and if the type is dropdown ie tpe=>"dropdown",i need to define select option using the name and value pairs dynamically.I need to define template using name and value pairs from the below hash.name is used to define text box or select option name ie label and value refers to its values.can any body suggest me how to define html template for this hash. Text box may contain default value when it is present in default=>"some value" ,need to show the default value to user and in the case of select option default=>"some value ",refers to selected in select option menu.If the enteries=>"more" means i need to define text area instead of text. can any one suggest me how to define HTML:: template for this hash. Thanks, srins. --------------------------------- Yahoo! FareChase - Search multiple travel sites in one click. |
From: David K. <da...@gi...> - 2005-10-28 18:25:52
|
Jason Purdy <ja...@jo...> wrote: > What I usually do is add another step and instead of stopping at the > template, I pass the template's output into HTML::FillInForm, which is > great for filling out ANY input fields (pop-up menus, etc). > > - Jason +1 to Jason's HTML::FillInForm recommendation. It is quite a handy module that has simplified much of my code (and shortened my development time) quite a bit! -dave > Arkady Grudzinsky wrote: >> What is the best way to generate input fields pre-filled with >> dynamic contents in HTML forms with HTML::Template and still be able >> to see the input fields when the template file is viewed in a >> browser without the script? <input type=text name=my_text >> value="<TMPL_VAR text_value>" /> >> >> works for text fields, but its not so trivial with the pop-up menus. >> >> Of course, I can generate input fields with Perl using either CGI or >> CGI::FormBuilder. >> But then, your template will look like this: >> >> <p>Your full name: <tmpl_var field-name> >> <p>Your email address: <tmpl_var field-email> >> <p>Choose a password: <tmpl_var field-password> >> <p>Please confirm it: <tmpl_var field-confirm_password> >> <p>Your home zipcode: <tmpl_var field-zipcode> >> >> When the template file is viewed in a browser, the input fields are >> not visible. If I write the code and ask an HTML web designer to >> work on templates, it would be hard for the web designer to see what >> the >> form looks like with the "invisible" fields. >> >> Did anyone have this problem? >> >> Thanks. >> >> Arkady. >> >> >> ------------------------------------------------------- >> This SF.Net email is sponsored by the JBoss Inc. >> Get Certified Today * Register for a JBoss Training Course >> Free Certification Exam for All Training Attendees Through End of >> 2005 Visit http://www.jboss.com/services/certification for more >> information _______________________________________________ >> Html-template-users mailing list >> Htm...@li... >> https://lists.sourceforge.net/lists/listinfo/html-template-users > > > ------------------------------------------------------- > This SF.Net email is sponsored by the JBoss Inc. > Get Certified Today * Register for a JBoss Training Course > Free Certification Exam for All Training Attendees Through End of 2005 > Visit http://www.jboss.com/services/certification for more information > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users |
From: Chris B. <htm...@pa...> - 2005-10-28 14:30:15
|
Rumour has it Mathew Robertson, on or about 25.Oct.2005 19:48, whispered: > you can do this with a filter: > > my $match = qr/(<[Tt][Mm][Pp][Ll]_[^>]+)\/>/; > my $filter = sub { > my $text_ref = shift; > $$text_ref =~ s/$match/$1>/g; > }; Hi Mathew, thanks for the help. I am already using filters so I can embed tags in form fields. I was just hoping for a new XHTML aware version :) -- Chris Beck - http://pacanukeha.blogspot.com Hanlon's Razor: Never attribute to malice that which is adequately explained by stupidity. |
From: Jason P. <ja...@jo...> - 2005-10-28 12:51:16
|
What I usually do is add another step and instead of stopping at the template, I pass the template's output into HTML::FillInForm, which is great for filling out ANY input fields (pop-up menus, etc). - Jason Arkady Grudzinsky wrote: > What is the best way to generate input fields pre-filled with dynamic contents > in HTML forms with HTML::Template and still be able to see the input fields > when the template file is viewed in a browser without the script? > > <input type=text name=my_text value="<TMPL_VAR text_value>" /> > > works for text fields, but its not so trivial with the pop-up menus. > > Of course, I can generate input fields with Perl using either CGI or > CGI::FormBuilder. > But then, your template will look like this: > > <p>Your full name: <tmpl_var field-name> > <p>Your email address: <tmpl_var field-email> > <p>Choose a password: <tmpl_var field-password> > <p>Please confirm it: <tmpl_var field-confirm_password> > <p>Your home zipcode: <tmpl_var field-zipcode> > > When the template file is viewed in a browser, the input fields are > not visible. If I write the code and ask an HTML web designer to work > on templates, it would be hard for the web designer to see what the > form looks like with the "invisible" fields. > > Did anyone have this problem? > > Thanks. > > Arkady. > > > ------------------------------------------------------- > This SF.Net email is sponsored by the JBoss Inc. > Get Certified Today * Register for a JBoss Training Course > Free Certification Exam for All Training Attendees Through End of 2005 > Visit http://www.jboss.com/services/certification for more information > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users |
From: Arkady G. <gru...@gm...> - 2005-10-28 06:46:40
|
What is the best way to generate input fields pre-filled with dynamic conte= nts in HTML forms with HTML::Template and still be able to see the input fields when the template file is viewed in a browser without the script? <input type=3Dtext name=3Dmy_text value=3D"<TMPL_VAR text_value>" /> works for text fields, but its not so trivial with the pop-up menus. Of course, I can generate input fields with Perl using either CGI or CGI::FormBuilder. But then, your template will look like this: <p>Your full name: <tmpl_var field-name> <p>Your email address: <tmpl_var field-email> <p>Choose a password: <tmpl_var field-password> <p>Please confirm it: <tmpl_var field-confirm_password> <p>Your home zipcode: <tmpl_var field-zipcode> When the template file is viewed in a browser, the input fields are not visible. If I write the code and ask an HTML web designer to work on templates, it would be hard for the web designer to see what the form looks like with the "invisible" fields. Did anyone have this problem? Thanks. Arkady. |
From: Mathew R. <mat...@ne...> - 2005-10-25 23:50:29
|
you can do this with a filter: my $match = qr/(<[Tt][Mm][Pp][Ll]_[^>]+)\/>/; my $filter = sub { my $text_ref = shift; $$text_ref =~ s/$match/$1>/g; }; $match is the regex used to find <TMPL_xxx ... /> tags. Then instantiate H::T with the 'filter' option. Hope this helps, Mathew Chris Beck wrote: >Hey all, > >Is there any way I could request that XHTML style <tmpl_var name="blah" /> also >be valid? > >Cheers, >Chris > > |
From: Mathew R. <mat...@ne...> - 2005-10-25 23:12:46
|
hehe - then you haven't tried my version of H::T ... I modified H::T so that it dynamically loads the appropriate escape module -> you simply do this: package HTML::Template::ESCAPE::HTML_JS; use HTML::Template::ESCAPE; $HTML::Template::ESCAPE::HTML_JS::VERSION = '1.0'; sub output { my $self = shift; $_ = shift if (@_ > 0); ...blah... $_; } then save the file somewhere in your PERL5LIB directory list. Mathew Alex Kapranoff wrote: >You are right, that would suffice. But as far as I understand, making >escape modules is not trivial. Escaping is not abstracted enough inside >HTML::Template. > >* Mathew Robertson <mat...@ne...> [October 20 2005, 08:22]: > > >>Is layered-escaping that is needed, or can we simply make a new escape >>module called, say "HTML_JS" >> >>Mathew >> >>Alex Kapranoff wrote: >> >> >> >>>* Philip Tellis <phi...@gm...> [October 18 2005, 16:02]: >>> >>> >>> >>> >>>>>s/pretty hard/impossible/; >>>>>That's why there's only 1 _default_. >>>>> >>>>> >>>>> >>>>> >>>>Oh well, "Perl is designed to make the easy jobs easy, without making >>>>the hard jobs impossible." >>>> >>>>I'd hoped that it was also, "... make impossible jobs pretty hard" >>>> >>>> >>>> >>>> >>>BTW, "double" or "layered" escaping is a very wanted feature. >>> >>>See: >>>====== >>><script> >>>item.innerHTML = "<strong><TMPL_VAR new_content></strong>"; >>></script> >>>====== >>> >>>This var needs first HTML, then JS escaping (in that order) or else >>>the code is likely just plain insecure. This task is not solved right >>>now. >>> >>> >>> >>> >>> > > > |
From: Chris B. <htm...@pa...> - 2005-10-25 17:56:08
|
Hey all, Is there any way I could request that XHTML style <tmpl_var name=3D"blah"= /> also be valid? Cheers, Chris --=20 Chris Beck - http://pacanukeha.blogspot.com "Privacy is what they take away when they want to torture you.=C2=94 -- The Earl of Spencer |
From: Alex K. <ka...@ra...> - 2005-10-24 11:01:43
|
You are right, that would suffice. But as far as I understand, making escape modules is not trivial. Escaping is not abstracted enough inside HTML::Template. * Mathew Robertson <mat...@ne...> [October 20 2005, 08:22]: > Is layered-escaping that is needed, or can we simply make a new escape > module called, say "HTML_JS" > > Mathew > > Alex Kapranoff wrote: > > >* Philip Tellis <phi...@gm...> [October 18 2005, 16:02]: > > > > > >>>s/pretty hard/impossible/; > >>>That's why there's only 1 _default_. > >>> > >>> > >>Oh well, "Perl is designed to make the easy jobs easy, without making > >>the hard jobs impossible." > >> > >>I'd hoped that it was also, "... make impossible jobs pretty hard" > >> > >> > > > >BTW, "double" or "layered" escaping is a very wanted feature. > > > >See: > >====== > ><script> > >item.innerHTML = "<strong><TMPL_VAR new_content></strong>"; > ></script> > >====== > > > >This var needs first HTML, then JS escaping (in that order) or else > >the code is likely just plain insecure. This task is not solved right > >now. > > > > > > -- Alex Kapranoff, $n=["1another7Perl213Just3hacker49"=~/\d|\D*/g]; $$n[0]={grep/\d/,@$n};print"@$n{1..4}\n" |
From: Josh C. <jos...@mi...> - 2005-10-22 08:50:21
|
Interesting... Morphing templates! I hadn't considered using filters to change the variable names themselves. Thanks for the suggestion. All best, Josh On Oct 21, 2005, at 3:29 PM, Mark A. Fuller wrote: > From: Josh Clark <jos...@mi...> > >> I imagine this is somewhat more expensive than includes. >> > Significantly so? Particularly in a CGI environment? Other downsides? > > Something I like to do when I want to gain more reuse of template > fragments than feels comfortable with lots of includes is > preprocess the templates. (Or, if it seems like there's a lot of > one-time static setup of a page and I'm concerned about performance > issues.) For tags I want to preprocess I name them "<PREPROC_*>". I > have a little command line script to use H::T to load a template, > use the filter option to change all "<TMPL_*>" to some other value, > change "<PREPROC_*>" to <TMPL_*>, output the template, apply a > regular expression to change the original <TMPL_*> values back to > TMPL_*. I write the data to the real (run-time) template directory. > > Another way to get creative with includes is use multiple > directories on the template path option. You can use variable > substitution to include templates from different directories at run > time. But, it sounds to me like what you're trying to do would > benefit more from preprocessing? > > Mark > > > ------------------------------------------------------- > This SF.Net email is sponsored by: > Power Architecture Resource Center: Free content, downloads, > discussions, > and more. http://solutions.newsforge.com/ibmarch.tmpl > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users > |
From: Mark A. F. <mar...@ea...> - 2005-10-21 13:29:51
|
From: Josh Clark <jos...@mi...> >I imagine this is somewhat more expensive than includes. Significantly so? Particularly in a CGI environment? Other downsides? Something I like to do when I want to gain more reuse of template fragments than feels comfortable with lots of includes is preprocess the templates. (Or, if it seems like there's a lot of one-time static setup of a page and I'm concerned about performance issues.) For tags I want to preprocess I name them "<PREPROC_*>". I have a little command line script to use H::T to load a template, use the filter option to change all "<TMPL_*>" to some other value, change "<PREPROC_*>" to <TMPL_*>, output the template, apply a regular expression to change the original <TMPL_*> values back to TMPL_*. I write the data to the real (run-time) template directory. Another way to get creative with includes is use multiple directories on the template path option. You can use variable substitution to include templates from different directories at run time. But, it sounds to me like what you're trying to do would benefit more from preprocessing? Mark |
From: Roger B. W. <ro...@fi...> - 2005-10-21 11:19:59
|
On Fri, Oct 21, 2005 at 01:08:25PM +0200, Josh Clark wrote: >I'm curious about what method folks use to combine several templates >into a single web page. The <tmpl_include> syntax obviously addresses >this. But it seems tempting in some cases to create a new >HTML::Template object for each template and include its output into a >single "master" template as a parameter, rather than via <tmpl_include>. Every template in bailii.org starts with <tmpl_include name=top.inc.tmpl> and ends with <tmpl_include name=bottom.inc.tmpl>. This saves me from having to worry about multiple HTML::Template objects, and gives me the flexibility of having a variant page layout if I want it. Roger |
From: Josh C. <jos...@mi...> - 2005-10-21 11:08:44
|
Hi, I'm curious about what method folks use to combine several templates into a single web page. The <tmpl_include> syntax obviously addresses this. But it seems tempting in some cases to create a new HTML::Template object for each template and include its output into a single "master" template as a parameter, rather than via <tmpl_include>. I imagine this is somewhat more expensive than includes. Significantly so? Particularly in a CGI environment? Other downsides? In a nutshell, it seems like this approach makes template maintenance easier by reducing duplication and, probably, the overall amount of template markup: 1) Encapsulation of parameters for reuse of templates. For example, I'd like to create a single template that handles form generation. But if I want to include several forms in a page (and they don't stack up nicely enough to fit a <tmpl_loop> pattern), then I can't use the same form template via <tmpl_include> because, of course, the template would use the same parameters for all three instances. But if I generate the html beforehand via several different $tmpl->output calls and pass that result to a template in parameters, then I can reuse the same template. 2) Nesting templates to reduce duplication within templates Generating included values via separate template objects lets me do something like this: a) Create html for two forms with a single form template. b) Include the forms as parameters to a screen/runmode template. c) Include the html of the runmode template into a master "wrapper" template. Some simple templates to illustrate that last example example... ** Master template: <html> <head> <title> <tmpl_var name="page_title"> </title> </head> <body> <h1> <tmpl_var name="page_title"> </h1> <tmpl_var name="page_content"> </body> </html> ---------- ** The "page_content" parameter gets generated by the appropriate screen/runmode template: <div id="column1"> <tmpl_var name="intro_text"> <tmpl_var name="form1"> </div> <div id="column2"> <tmpl_var name="form2"> </div> ---------- ** The "form1" and "form2" parameters get generated by the same form template: <form action="<tmpl_var name="action_url">" method="post"> <tmpl_var name="form_title"> <tmpl_loop name="fieldset"> <div class="fieldset"> <h2><tmpl_var name="category_name"></h2> <tmpl_var name="category_description"> <tmpl_loop name="fields"> ... generate input fields ... </tmpl_loop> </div> </tmpl_loop> </form> Thanks for your thoughts and advice! Josh |
From: Mathew R. <mat...@ne...> - 2005-10-21 03:54:18
|
There are a number of reasons why this is a bad thing, among them: - performance -> you cant make user of cached templates - error messages can be extremenly cryptic. That said, I maintain a modified version of H::T which does include this feature - you can download it from here: http://members.optusnet.com.au/~mathew Mathew John Wang wrote: > I've been using HTML::Template for a while now and am familiar > TMPL_INCL. If you wanted the main template to be nested inside an > "outer" template, say one that contained the header, footer, and > navigation, you could do that in Perl: instantiate HTML::Template > twice and put the output of one as a param in another. > > Just recently I did a little playing around with TT and found it's > WRAPPER directive very useful. It basically does the same thing but > because it's built into the templating system, it's a lot cleaner. > > This seems a useful and basic enough feature that I was wondering if > there was a reason it wasn't included with HTML::Template? > Performance, something else? > > Just curious, > John |
From: John W. <joh...@gm...> - 2005-10-21 03:01:01
|
I've been using HTML::Template for a while now and am familiar TMPL_INCL. I= f you wanted the main template to be nested inside an "outer" template, say one that contained the header, footer, and navigation, you could do that in Perl: instantiate HTML::Template twice and put the output of one as a param in another. Just recently I did a little playing around with TT and found it's WRAPPER directive very useful. It basically does the same thing but because it's built into the templating system, it's a lot cleaner. This seems a useful and basic enough feature that I was wondering if there was a reason it wasn't included with HTML::Template? Performance, something else? Just curious, John |
From: Mathew R. <mat...@ne...> - 2005-10-20 04:24:45
|
Is layered-escaping that is needed, or can we simply make a new escape module called, say "HTML_JS" Mathew Alex Kapranoff wrote: >* Philip Tellis <phi...@gm...> [October 18 2005, 16:02]: > > >>>s/pretty hard/impossible/; >>>That's why there's only 1 _default_. >>> >>> >>Oh well, "Perl is designed to make the easy jobs easy, without making >>the hard jobs impossible." >> >>I'd hoped that it was also, "... make impossible jobs pretty hard" >> >> > >BTW, "double" or "layered" escaping is a very wanted feature. > >See: >====== ><script> >item.innerHTML = "<strong><TMPL_VAR new_content></strong>"; ></script> >====== > >This var needs first HTML, then JS escaping (in that order) or else >the code is likely just plain insecure. This task is not solved right >now. > > > |
From: Carl F. <fir...@gm...> - 2005-10-18 13:14:13
|
On 18/10/05, Philip Tellis <phi...@gm...> wrote: > Oh well, "Perl is designed to make the easy jobs easy, without making > the hard jobs impossible." > > I'd hoped that it was also, "... make impossible jobs pretty hard" touch=E9 :) A new option to allow HTML::Template to load up HTML::Parser and decide itself which escaping to use? Carl |
From: Alex K. <ka...@ra...> - 2005-10-18 12:25:50
|
* Philip Tellis <phi...@gm...> [October 18 2005, 16:02]: > >s/pretty hard/impossible/; > >That's why there's only 1 _default_. > > Oh well, "Perl is designed to make the easy jobs easy, without making > the hard jobs impossible." > > I'd hoped that it was also, "... make impossible jobs pretty hard" BTW, "double" or "layered" escaping is a very wanted feature. See: ====== <script> item.innerHTML = "<strong><TMPL_VAR new_content></strong>"; </script> ====== This var needs first HTML, then JS escaping (in that order) or else the code is likely just plain insecure. This task is not solved right now. -- Alex Kapranoff, $n=["1another7Perl213Just3hacker49"=~/\d|\D*/g]; $$n[0]={grep/\d/,@$n};print"@$n{1..4}\n" |
From: Philip T. <phi...@gm...> - 2005-10-18 12:02:56
|
Sometime Today, CF cobbled together some glyphs to say: > s/pretty hard/impossible/; > That's why there's only 1 _default_. Oh well, "Perl is designed to make the easy jobs easy, without making the hard jobs impossible." I'd hoped that it was also, "... make impossible jobs pretty hard" -- The debate rages on: Is PL/I Bachtrian or Dromedary? |