Hello,
I would like to share a Stash (Template::Stash::XS) object between two
distinct Template objects, but am having no luck.
My code looks like this:
use Template;
use Template::Stash::XS;
my $stash = Template::Stash::XS->new();
my $template_one = Template->new( {STASH => $stash} );
# ......
my $template_two = Template->new( {STASH => $stash} );
----------------------------------------------------------------------------
---------------------
where one template looks like:
----------------------------------------------------------------------------
----------------------
[% SET somevar = "somevalue" %]
And the other template references that value:
----------------------------------------------------------------------------
----------------------
the value of somevar is [% somevar %]
The end result that I would like is to be able to have one template set some
variables, then allow future template processors to use the values set.
I would rather work with a stash object than a reference to some global
memory (a stash would seem to make a good consistent interface transparent
to the template writers).
And yes, the template objects are distinct (they are used by separate
objects themselves and are not shared.
Any Ideas for the best way to do this?
Should I simply pass around a hash reference to my template objects? For
example, use "[% SET global.somevar = "somevalue" %]" ????
Thank you!
Bryan Shannon
Bryan Shannon
Senior Applications Developer
Tribune Media Services
(800) 424-4747 x295
[EMAIL PROTECTED]