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:
In reply to Stash access for a Template::Plugin plugin by thomas895
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |