5

I'm using TT from perl, and trying to insert into template and process a variable, that itself contains TT directives.

So, in the script I'm writing smth like:

$var{descr} = "[% pid = 1; INSERT plink.par %]";

And then in TT template (which received \%var):

[% BLOCK parsedDescr %]
[% descr %]
[% END %]
<p>[% INCLUDE parsedDescr %]

And I'm expecting pid variable being set to "1", and plink.par file inserted. But instead I get on my html page exactly contents of the variable descr:

[% pid = 1; INSERT plink.par %]

i.e., this variable stays unprocessed by TT.

How do I make TT process it's contents?

1 Answer 1

5

You can use the eval filter:

<p>[% descr | eval %]

From the linked manpage:

The eval filter evaluates the block as template text, processing any directives embedded within it. This allows template variables to contain template fragments, or for some method to be provided for returning template fragments from an external source such as a database, which can then be processed in the template as required.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.