Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Accessing the stash within a TT file

by thunders (Priest)
on Jun 30, 2009 at 18:04 UTC ( #776128=note: print w/ replies, xml ) Need Help??


in reply to Accessing the stash within a TT file

Yes, you can directly acess the stash from a PERL block.

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);
output:
$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' );


Comment on Re: Accessing the stash within a TT file
Select or Download Code
Re^2: Accessing the stash within a TT file
by thunders (Priest) on Jun 30, 2009 at 18:17 UTC

    That being said, what exactly are you trying to do? It's already possibly to PROCESS a file from another TT file. Is there something specific you need to do that PROCESS does not do?

    If you simply need to modify existing stash variables, or add new stash variables, you could probably get away with a TT wrapper file that manipulates variables and then calls PROCESS on another tt file supplied as an argument.

Re^2: Accessing the stash within a TT file
by Anonymous Monk on Jul 01, 2009 at 01:02 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://776128]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (14)
As of 2014-09-19 14:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (140 votes), past polls