Hello all,
Thanks in advance for any feedback :)
I can't seem to find out if/how this is possible but:
If a variable passed to process() is a string that also includes TT
directives, is there a way to have the variable's contents processed?
Similar to PROCESS or INCLUDE but with a variable's contents
For example, how do we get this:
my $stp = "A: [% a %]\nB: [% b %]\nC: [% c %]";
$tt->process(\$stp, { a=>"AAA", b=>"BBB", c=>'C is A: [% a %]'}, \
$buf) || die $tt->error();
To render
A: AAA
B: BBB
C: C is A: AAA
instead of:
A: AAA
B: BBB
C: C is A: [% a %]
The only trick so far is to process() it twice, which seem excessive
since we have to reprocess all the output and not just pieces of text
within it:
#!/usr/bin/perl
use Template;
my $tt = Template->new();
# how to get 'c' processed, as in: C is A: AAA
my $stp = "A: [% a %]\nB: [% b %]\nC: [% c %]";
my $buf;
$tt->process(\$stp, { a=>"AAA", b=>"BBB", c=>'C is A: [% a %]'}, \
$buf) || die $tt->error();
$tt->process(\$buf, { a=>"AAA", b=>"BBB", c=>'C is A: [% a %]'}) ||
die $tt->error();_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates