Brad Choate <[EMAIL PROTECTED]> writes:

> Simple task, or at least you'd think so.
>
> I want to load the source for a template file by filename, utilizing
> the template path search support in Template Toolkit. I've been able
> to retrieve a Template::Document, but I have no access to the source
> of the template itself.
>
> Template::Provider has the path search code, but right after _load-ing
> the template, it compiles it, overwriting the text element of the hash
> which held the source.
>
> The end goal here is to preprocess the template source, then recompile
> and update the Template::Document.

Just guessing - your "preprocess" is not TT's preprocess, but some
other form of munging the template *before* TT gets its hands at it?

I recall that I've done something like that in the past, and without
any hacking^Wsubclassing of TT modules....

1) Slurp your file into a TT variable with

     [% template_source = INSERT template.file.name %]

2) Do whatever you want to template_source.  If your preprocessor is
   Perl, feed the variable to a plugin or filter wrapper for your
   preprocessor.

3) update using the eval filter:

     [% template_source | eval %]

-- 
HTH,
haj


_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to