[Templates] How to redirect template output into another file?
Simon Wilcox
essuu@ourshack.com
Mon, 6 Oct 2003 02:44:51 +0100 (BST)
On Tue, 16 Sep 2003, Andy Wardley wrote:
> You can always add it manually. Something like this:
>
> FILTER redirect(page);
> PROCESS product/page WRAPPER site/wrapper;
> END
Finally had a need to actually use this and I seem to be doing something
dumb !
Here's a snippet from my code:
my $tt = Template->new(
INCLUDE_PATH => 'util',
PROCESS => 'wrapper.tt',
PRE_PROCESS => 'config.tt',
OUTPUT_PATH => $outdir,
RELATIVE => 1,
EVAL_PERL => 1,
PRE_CHOMP => 1,
);
config.tt loads common variables and so on. Here's wrapper.tt
[% IF dataset;
wrapper = files.$dataset.wrapper;
WRAPPER $wrapper;
content;
END;
ELSE;
content;
END %]
Basically it chooses the actual wrapper template at runtime. Here's a
wrapper (called sentio.tt):
<?xml version="1.0" encoding="UTF-8"?>
<sentiocontent id="1" type="[% template.SentioType %]">
[% PROCESS $template %]
</sentiocontent>
And here's a snippet from a template I'm trying to double-wrap:
[% FILTER redirect( opfile );
wrapper = files.$dataset.wrapper;
PROCESS xml/sentioquestions.tt WRAPPER $wrapper;
END %]
This gets me an error "file error - recursion into 'xml/sentio.tt'". If I
add RECURSION => 1 to the call to new(), it spins out and eats memory.
Any pointers as to my error here ?
Simon.