UPDATE-START:
I found out that eval does almost what I asked - except you need to include | eval which I would like to avoid if possible.
I looked before posting here and I didn't see - it seems that meerly asking a question unblinded me somehow - and this isn't the first time either.
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:
Copyright © 2008 ([% site_name %]).
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:
- move variable value to a real file and then use INCLUDE/PROCESS
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.
- Create two TT objects, process all such variables with one in a loop (no wrapper and all), and then just do as normal in the other (wrapper and all).
Loop is already there due to other things - though 3rd is better variant of this it seems.
- Run TT processing two times, first run to do the real processing (include wrapper ...etc) and then the second to process the stuff read from variables (if any such variables).
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.
Another idea is to change TT and extend it so it can read BLOCK content from a DB - but honestly - I'd like to skip this one due to lack of available time.
Have you tried freelancing? Check out
Scriptlance - I work there. For more info about Scriptlance and freelancing in general check out
my home node.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.