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?
Choose Template > New Variable from the editor toolbar (or choose an existing variable to add it to the page) Enter a name for the variable. Press Enter (by default this will create a single-line text input field)
A variable template may be introduced by a template declaration at namespace scope, where variable-declaration declares a variable. When used at class scope, variable template declares a static data member template.
In the template, you use the hash symbol, # , to declare a template variable. The following template variable, #phone , declares a phone variable with the <input> element as its value.
Template Inheritance The @section directive, as the name implies, defines a section of content, while the @yield directive is used to display the contents of a given section.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With