[Templates] How to redirect template output into another file?

Andy Wardley abw@andywardley.com
Mon, 6 Oct 2003 09:38:26 +0100


Simon Wilcox wrote:
> my $tt = Template->new(
>                 INCLUDE_PATH => 'util',
>                 PROCESS => 'wrapper.tt',

Use the WRAPPER option:
                  WRAPPER => wrapper.tt

wrapper.tt:
 [% IF dataset;
       wrapper = files.$dataset.wrapper;
       WRAPPER $wrapper;
         content;
       END;
     ELSE;
       content;
     END
 %]

Also use 'content' in your other wrappers.

wrapper/sentio.tt:
  <?xml version="1.0" encoding="UTF-8"?>
  <sentiocontent id="1" type="[% template.SentioType %]">
     [% content %] 
  </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 %]
> 

I'm a bit lost here...

The idea of using an automatic WRAPPER/PROCESS template is to avoid 
having to worry about wrappers in your main templates.

You should just have your content in here and leave the auto-WRAPPER
to worry about wrapping it.

    [% PROCESS xml/sentioquestions.tt %]

A