Thanks for the really quick response. 

Still it seems that I'm missing something essential. If I do it the way you 
explained, I always get the unmodified values:

[% name="John" %]

in the template still results in printing "Fred" if I write

print $stash{name};


-------- Original-Nachricht --------
> Datum: Tue, 19 Jun 2012 23:35:10 -0400
> Von: Clayton Scott <clayton.sc...@gmail.com>
> An: Daniel Degenhardt <mr_slowd...@gmx.de>
> CC: templates@template-toolkit.org
> Betreff: Re: [Templates] Accessing template variables after process

> On Tue, Jun 19, 2012 at 5:56 PM, Daniel Degenhardt
> <mr_slowd...@gmx.de>wrote:
> 
> > Hello,
> >
> > is there a way to access the (modified) template variables from perl
> > script after calling process? The reason I like to do that, is that I
> want
> > to set the output filename from within the template file. Something like
> > that:
> >
> > [% filename = "$somevar.$someextension" %]
> >
> >
> Sure, I've done this a lot. You can modify the variables passed in, I
> always find it easiest to do it this way:
> 
> my %stash = ( name => 'Fred',  email => 'f...@slatequarry.com', headers =>
> {});
> 
> my $output;
> 
> $tt->process($template, \%stash, \$output);
> 
> sendmail( to => $stash{email}, subject => $stash{headers}{subject}, body
> =>
> $output );
> 
> 
> -- somewhere in a template --
> 
> [% headers.subject = name _ ', special on brontosaurus burgers' %]
> 
> [% name %], come on down to the Drive-In and get 2 for 1 bronto burgers
> 
> Sincerely,
> The Management
> 
> 
> This code/ template are untested,
> Clayton
> 
> 
> > From perl i like to read out the filename variable and save the
> > instantiated template file under that name.
> >
> > Any hints welcome!
> >
> > Thanks in advance,
> >
> > Daniel.
> > _______________________________________________
> > templates mailing list
> > templates@template-toolkit.org
> > http://mail.template-toolkit.org/mailman/listinfo/templates
> >
> 
> 
> 
> -- 
> 
> Clayton Scott
> clayton.sc...@gmail.com

-- 
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de

_______________________________________________
templates mailing list
templates@template-toolkit.org
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to