[Templates] Getting at template variables outside of a template

Andy Wardley abw@wardley.org
Sat, 15 Sep 2007 07:56:17 +0100


Mark Wagner wrote:
> Why does the Template::Stash get gutted after the the process?

So that variables set in one template don't have side-effects in the next 
template you happen to process.

> $config->{'export'} = { };
> $hack = '[% PERL %] $stash->set([ "export", 0, "stash", 0 ], $stash); [% END %]';
> $tt->process(\$hack, $config));

That'll work, but be careful.  You've created a circular reference so your 
application may bleed memory if you run it for long enough.

Cheers
A