thomas895 has asked for the wisdom of the Perl Monks concerning the following question:
Maybe I'm looking in all the wrong places, but I can't seem to figure out how to access the stash ref from a Template plugin.
For example:
sub new { my( $class, $context ) = @_; #Stash my $stash = $context->{'STASH'} or die( "No stash given" ); #Bless object ref my $self = bless( { CONTEXT => $context, DBH => $stash->get('DBH') }, $class ); return $self; }
...dies as if the stash does not exist. However, when I get a dump of the @_ array, it does appear:
'STASH' => bless( { #...megabytes of data omitted for brevity }, 'Template::Stash' );
However, the docs state in Template::Plugin that the second argument(including the class name) is a Template::Context object, which contains the stash. And the dump above includes a full stash.
I have tried the following as well:
my $stash = $context->stash; #Returns a TT2 undef error "Can't call me +thod "stash" on an undefined value"
So my question is:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Stash access for a Template::Plugin plugin
by Anonymous Monk on Jan 02, 2012 at 04:30 UTC | |
|
Re: Stash access for a Template::Plugin plugin
by Khen1950fx (Canon) on Jan 02, 2012 at 05:53 UTC |