Thanks Andy, this is a better approach using the
Wrapper option ..

-Kiran

--- Andy Wardley <[EMAIL PROTECTED]> wrote:

> Kiran Kumar wrote:
> > Can I do something like this for older scripts
> which
> > needs header and footer passed back
> > 
> > $header = $template->process("test.tt", Only block
> 1, {data set})
> > $footer = $template->process("test.tt", Only block
> 3, {data set})
> > 
> > and for newer scripts which pass all the data .
> > 
> > $template->process("test.tt",{block1 , block2,
> block3}{data set}); 
> 
> Could you do this:
> 
>   $header = $template->process('header', $data);
>   $footer = $template->process('footer', $data);
> 
> And for newer scripts:
> 
>   $content = $template->process('test.tt', $data);
> 
> Where test.tt looks like this:
> 
>   [% INCLUDE header %]
>   ...content...
>   [% INCLUDE footer %]
> 
> This is assuming that you've got one header and
> footer shared across
> all pages.
> 
> If instead you want each template to be able to
> define it's own header
> and footer, then you should probably do something
> like this:
> 
> test.tt:
>   [% BLOCK header %]
>   This is the header
>   [% END %]
> 
>   This is the content.
> 
>   [% BLOCK footer %]
>   This is the footer
>   [% END %]
> 
> Then use the WRAPPER option to define templates that
> create one or more different 
> views of the page.
> 
> full_page:
>    [% INCLUDE header %]
>    [% content %]
>    [% INCLUDE footer %]
> 
> header_only:
>    [% INCLUDE header %]
> 
> footer_only:
>    [% INCLUDE footer %]
> 
> 
> my $ttfp = Template->new( WRAPPER => 'full_page' );
> my $tthd = Template->new( WRAPPER => 'header_only'
> );
> my $ttft = Template->new( WRAPPER => 'footer_only'
> );
> 
> $ttfp->process('test.tt', $data);     # full page:
> header, content, footer
> $tthd->process('test.tt', $data);     # header only
> $ttft->process('test.tt', $data);     # footer only
> 
> 
> HTH
> A
> 
> 
> _______________________________________________
> templates mailing list
> [email protected]
>
http://lists.template-toolkit.org/mailman/listinfo/templates
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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

Reply via email to