Thread: Re: [htmltmpl] Nesting TMPL tags
Brought to you by:
samtregar
From: Mark A. F. <mar...@ea...> - 2005-07-12 13:47:30
|
From: Philip Tellis <phi...@gm...> >> I want to TMPL_INCLUDE files, the problem is that the file I want to >> include itself is variable. I want a construct of the sort >> >> <TMPL_INCLUDE NAME="<TMPL_VAR NAME=file_name>"> > > ... What you want is to use a filter that >preprocesses your template. Change your template to something like >this: > ><TMPL_INCLUDE NAME="%file_name%"> Or, organize your included templates into directories that can be referenced with the "path =>" parameter to the "new" method. Something like: path => [ '/path/to/templates', '/' . $include . '/path' ] Mark |
From: Rajesh_K <Rajesh_K@Satyam.com> - 2005-07-12 15:49:43
|
Hi Mark, Philip, Is this part of the HTML::Template::expr package? I don't see any %...% construct in HTML::Template. Sorry I am asking you this... ppm is down at activestate and I cant get at the expr module! Rajesh -----Original Message----- From: htm...@li... [mailto:htm...@li...] On Behalf Of Mark A. Fuller Sent: Tuesday, July 12, 2005 7:17 PM To: Philip Tellis; HTML::Template List Subject: Re: [htmltmpl] Nesting TMPL tags From: Philip Tellis <phi...@gm...> >> I want to TMPL_INCLUDE files, the problem is that the file I want to >> include itself is variable. I want a construct of the sort >> >> <TMPL_INCLUDE NAME=3D"<TMPL_VAR NAME=3Dfile_name>"> > > ... What you want is to use a filter that >preprocesses your template. Change your template to something like >this: > ><TMPL_INCLUDE NAME=3D"%file_name%"> Or, organize your included templates into directories that can be referenced with the "path =3D>" parameter to the "new" method. Something like: path =3D> [ '/path/to/templates', '/' . $include . '/path' ] Mark ------------------------------------------------------- This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual core and dual graphics technology at this free one hour event hosted by HP, AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar _______________________________________________ Html-template-users mailing list Htm...@li... https://lists.sourceforge.net/lists/listinfo/html-template-users DISCLAIMER: This email (including any attachments) is intended for the sole use of = the intended recipient/s and may contain material that is CONFIDENTIAL = AND PRIVATE COMPANY INFORMATION. Any review or reliance by others or = copying or distribution or forwarding of any or all of the contents in = this message is STRICTLY PROHIBITED. If you are not the intended = recipient, please contact the sender by email and delete all copies; = your cooperation in this regard is appreciated. |
From: Philip T. <phi...@gm...> - 2005-07-12 15:59:58
|
Sometime Today, R cobbled together some glyphs to say: > Is this part of the HTML::Template::expr package? I don't see any > %...% construct in HTML::Template. Sorry I am asking you this... ppm > is down at activestate and I cant get at the expr module! No, you have to write your own code to parse it. You can use any format you like. I just picked %...% at random. Look at the documentation for HTML::Template, specifically the 'filter' parameter to the constructor. Philip -- Would you *______really* want to get on a non-stop flight? -- George Carlin |
From: Mark F. <mar...@ea...> - 2005-07-12 17:19:34
|
From: "Rajesh_K" <Rajesh_K@Satyam.com> >Is this part of the HTML::Template::expr package? I don't see any %...% construct in HTML::Template. Sorry I am asking you this... ppm is down at activestate and I cant get at the expr module! Rajesh, Philip is suggesting that you markup your template so that you can perform substitution upon a token inside the template using the "filter" parameter to the "new" method. You can mark it up any way you want. He's suggesting you use % characters to make it unique. Then you do something like this: ========= my $filter = sub { my $text_ref = shift; $$text_ref =~ s#MY_INCLUDE#$include_filename#g; } # end filter $template = $HTML::Template->new($page . '.html', filter => [ { sub => $filter, format => 'scalar' }, ]); ========== Or, as I said, you can use the "path" parameter to the "new" method and pass it multiple paths (some or all of which are defined at the time the "new" method is called.). If you can organize your includes into directories matching the criteria by which you'd like to load them with TMPL_VAR, you could effectively accomplish the same thing by specifying variables on the path parameter. I had a *really* hard time with this concept because I believed H::T was pulling in the includes at the time it is output. I too thought I should be able to use TMPL_VAR to change include names. But, it's pulling them in at the time you call "new." So, your choice is to organize them into directories and use multiple paths for H::T to search. Or, use the filter to change values to what you want them to be (before it evaluates the TMPL_ tags). Mark |