Blessings upon ye, Monks of Perl.
I recently embarrassed myself by asking TT & templates from data?. And here is another, hopefully less stupid question:
Is there a way to make Template::Toolkit process the contents of a variable inside of a template?
E.G.
my $vars = { header => 'hello, [% name %]', footer => 'goodbye, [% name %]', name => 'Dave', } my $template = <<"END"; [% header %] I'm afraid I can't do that [% footer %] END my $TT = Template->new(); my $output; $TT->process(\$template,$vars,\$output) || die $TT->error();
If "header" and "footer" were external files, I could INCLUDE them, but they are scalars.
I was able to make it work by running process twice:
$TT->process(\$template,$vars,\$output) || die $TT->error(); $TT->process(\$output,$vars,\$output) || die $TT->error();
But I'd rather do something less kludgey and more scalable.
Thanks for any ideas!
--Pileofrogs
In reply to Yet Another Stupid TT Question by pileofrogs
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |