Re: [Templates] Accessing "global" vars inside an INCLUDE

[prev] [thread] [next] [Date index for 2004/05/21]

From: Andy Wardley
Subject: Re: [Templates] Accessing "global" vars inside an INCLUDE
Date: 17:04 on 21 May 2004
Gavin Estey wrote:
> I've worked around it by
> passing a hash to exploit the fact that the localisation isn't a deep copy,
> but this seems kind of icky. Is there something nicer?

TT already provides a 'global' hash for precisely this kind of thing.

> [% SET count = { count => 1 } %]
> [% INCLUDE test_block global=count %]
> [% INCLUDE test_block global=count %]
> [% INCLUDE test_block global=count %]

So that can instead be:

  [% global.count = 1 %]
  [% INCLUDE test_block %]

> [% BLOCK test_block %]
...this remains exactly the same...
> [% END %]

It's still a bit icky, but at least it's builtin icky  :-)

A


_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

Re: [Templates] Accessing "global" vars inside an INCLUDE
Andy Wardley 17:04 on 21 May 2004

Generated at 08:55 on 15 Mar 2005 by mariachi v0.52