[Templates] Accessing "global" vars inside an INCLUDE
[prev]
[thread]
[next]
[Date index for 2004/05/21]
I've got a template that uses INCLUDE so the block's variables are
localised. However there's a "global" variable I need to update inside the
block (to keep track of a count in this instance). 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?
[% SET count = { count => 1 } %]
[% INCLUDE test_block global=count %]
[% INCLUDE test_block global=count %]
[% INCLUDE test_block global=count %]
[% BLOCK test_block %]
[% SET i = 0 %]
[% WHILE i < 10 %]
i = [% i %], count = [% global.count %]
[% i = i + 1; global.count = global.count + 1 %]
[% END %]
[% END %]
Cheers,
Gavin.
_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates
 |
[Templates] Accessing "global" vars inside an INCLUDE
Gavin Estey 16:20 on 21 May 2004
|