techcode has asked for the wisdom of the Perl Monks concerning the following question:
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.UPDATE-END.
I need a way to evaluate/process TemplateToolkit variables from within a TT template. As in case of Process/Include when stuff "inside" is processed.
So in variable I have something like this, and it could also contain other TT directives:
In reality value for that is coming from a DB - so I can't simply place that in a BLOCK or external file. Ideas I have so far - but honestly, non of the solutions is optimal:Copyright © 2008 ([% site_name %]).
It would mean you need to change the original template to have that PROCESS whatever, and there is a problem of values that don't exist (not yet entered or simply not used) as I would need to create empty files for them so I don't get errors. On top of having to manage files in the first place.
Loop is already there due to other things - though 3rd is better variant of this it seems.
This one seems best of the 3 - quite easy to implement, but will probably hurt performance somewhat and screw up TT built in caching. Though I might implement my own caching anyway.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: "Evaluating" TemplateToolkit variables.
by kyle (Abbot) on Aug 16, 2008 at 19:16 UTC |