in reply to Accessing the stash within a TT file
Yes, you can directly acess the stash from a PERL block.
output:use Template; my $tt = Template->new({EVAL_PERL => 1}); my $vars = { x => [1,2,3] }; my $text = q{ [%PERL%] use Data::Dumper; print STDOUT Dumper $stash [%END%] }; $tt->process(\$text,$vars);
$VAR1 = bless( { 'template' => bless( { '_DEFBLOCKS' => {}, '_BLOCK' => sub { "DUMMY" }, 'modtime' => 1246384891, 'name' => 'input text', '_HOT' => 1 }, 'Template::Document' ), 'global' => {}, 'inc' => sub { "DUMMY" }, 'x' => [ 1, 2, 3 ], 'dec' => sub { "DUMMY" }, 'component' => $VAR1->{'template'}, '_DEBUG' => 0, '_PARENT' => bless( { 'global' => $VAR1->{'global'}, 'inc' => $VAR1->{'inc'}, '_DEBUG' => 0, 'dec' => $VAR1->{'dec'}, '_PARENT' => undef }, 'Template::Stash::XS' ) }, 'Template::Stash::XS' );
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Accessing the stash within a TT file
by thunders (Priest) on Jun 30, 2009 at 18:17 UTC | |
Re^2: Accessing the stash within a TT file
by Anonymous Monk on Jul 01, 2009 at 01:02 UTC |
In Section
Seekers of Perl Wisdom