On Thu, Jan 24, 2002 at 01:04:36PM +0000, Simon Wilcox wrote:
> And am I correct in assuming that it is a concise form of this ?
> 
> [%- WRAPPER page %]
> 
> ..template stuff..
> 
> [% END -%]

Yes.  If you use the PROCESS option (or 'process' in .ttreerc) then 
TT stores a reference to the regular template in the 'template' variable
and processes your PROCESS template instead.

  my $tt = Template->new( PROCESS => 'page' );

In the simple case your 'page' template can look like this:

  <html>
  blah blah
  [% PROCESS $template %]
  blah blah
  </html>

But often it's better to do 'page' like this:

  [% WRAPPER layout;
       PROCESS $template;
     END
  %]

and have 'layout' look like this:

  <html>
  blah blah
  [% content %]
  blah blah
  </html>

That way, you can also use the same 'layout' to create pages on the fly:

  [% FILTER redirect('some/other/page.html') %]
     [% WRAPPER layout %]
     Blah blah blah
     [% END %]
  [% END %]

Or, for a full-on gnarly example:

  [% INCLUDE user/info 
       WRAPPER layout title="$user.name homepage"
         FILTER redirect("user/$user.id/info.html")
           FOREACH user = userlist
  %]


HTH
A



Reply via email to