RE: [htmltmpl] is it possible to use var in include
Brought to you by:
samtregar
From: Rajesh_K <Raj...@Sa...> - 2005-09-29 11:40:47
|
I am doing this quite successfully with the following code: In the HTML template <TMPL_INCLUDE NAME=3D"%mainbody%"> In the perl script my $filter =3D \&tmpl_filter; my $template =3D HTML::Template->new(filename =3D> 'insider_tmpl.html', path=3D> $self->param('tmpl_path'), filter=3D>$filter); sub tmpl_filter()=20 { my $text_ref =3D shift; $$text_ref =3D~ s/%mainbody%/$body_include/g; }; Regards, Rajesh -----Original Message----- From: htm...@li... [mailto:htm...@li...] On Behalf Of Peter Leonard Sent: Wednesday, September 28, 2005 7:48 PM To: mic...@cs... Cc: htm...@li... Subject: Re: [htmltmpl] is it possible to use var in include Michael, In my experience, the only way to make that work is by making two passes through HTML::Template, creating a custom filter on the first pass. So your template syntax would look like this: [TMPL_INCLUDE NAME=3D<TMPL_VAR NAME=3Dmod>] The first pass would set the 'mod' param, but ignore the outer tags. The=20 second pass would use a filter to convert all the [TMPL] tags to standard=20 <TMPL> tags, and then behave as normal. Something like the following perl-pseudo: $tmpl->param(mod=3D>'include.tmpl'); my $pass =3D $tmpl->output(); my $tmpl2 =3D HTML::Template->new(scalarref =3D> $pass, filter =3D> sub { $_ =3D~ s/\[(TMPL[^\]]+)\]/<$1>/gis; }); $tmpl2->param(%other_vars); return $tmpl2->output(); HTH, --pete On Wed, 28 Sep 2005 mic...@cs... wrote: > Hello all, > > Is that not possible? <TMPL_INCLUDE NAME=3D<TMPL_VAR NAME=3Dmod>> > Cause depending in which mode I open the template I want to show up a > differnt body (e.g. start page, register page, search page...) > > Regards > Michael ---- Peter Leonard pe...@pe... ------------------------------------------------------- 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 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. |