* Michael Henson <[EMAIL PROTECTED]> [2002-12-29 19:17]:
> I have come a cross a situation in which I would like to be able INCLUDE
> another template and provide a set of local variables for that template,
> but not give the template access to the outer environment. This is
> namely to stop prevent name clashes of the internal variables (many of
> which can be arguments themselves). 

Someone requested something similar back in September, and I made a
patch that created a new directive, DO, that created a new Stash for
the processed file.

With this patch applied, your example:

> [% INCLUDE foo %]
>       bar = "zot"
> [% END %]

Would be:

  [% DO foo %]
    bar = "zot"
  [% END %]

> So foo would have access to whatever defaults were set up inside of it,
> and bar. Any suggestions would be most welcome. If some easy way does
> not exist I would be interested in augmenting the toolkit to have such a
> behavior.

There isn't an "easy" way -- you need to patch the parser and regenerate
the grammar.  See the three anchored at
<http://lists.ourshack.com/pipermail/templates/2002-September/003708.html>,
and my followup, which both has the patches and instructions on how to
apply them.  You'll need Parse::YAPP installed, which you normally don't
need to install TT, because the grammar will need to be rebuilt.

Finally, this is not well-tested, as it was a one-off, and I don't
think I heard from the original questioner whether it was sufficient (or
if he even used it).

(darren)

PS You might need to grab the mbox file
(<http://lists.ourshack.com/pipermail/templates/2002-September.txt.gz>)
to get the attachments.

-- 
All journalists have a novel in them, which is where it belongs.

_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.ourshack.com/mailman/listinfo/templates

Reply via email to