Thread: [htmltmpl] Dynamically including templates?
Brought to you by:
samtregar
From: Todd C. <htm...@ch...> - 2004-01-07 19:16:06
|
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 |
From: Timm M. <tm...@ag...> - 2004-01-07 19:26:25
|
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: 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: 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: 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 |
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 |