On Tue, 15 Oct 2002, Hrvoje Niksic wrote:

> A colleague asked an interesting question about tmpl_includes.  The
> point was, how do I make an include reusable from multiple pages?  I
> answered that you could simply write a function that populated the
> template variables that the include required.  A user of the include
> would be required to call the function, and that would constitute
> reusability.
>
> He objected that this could cause namespace collisions: you have to
> carefully check that the includes you're using don't use a variable
> name you'd like to use in the template.  Otherwise, the filler
> function will clobber some of your variables.

There's no need for new syntax, just create a separate HTML::Template
object for the reusable include and populate it separately.  You can do
this in a separate module for added security.  Then, when you're ready to
fill in the include do:

  $main_template->param(inner_template => $inner_template->output());

And in your main templates, use

  <tmpl_var inner_template>

instead of a <tmpl_include>.

I've used this strategy to good effect a number of times.

-sam




-------------------------------------------------------
This sf.net email is sponsored by: viaVerio will pay you up to
$1,000 for every account that you consolidate with us.
http://ad.doubleclick.net/clk;4749864;7604308;v?
http://www.viaverio.com/consolidator/osdn.cfm
_______________________________________________
Html-template-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/html-template-users

Reply via email to