[Templates] trying to leave HTML::Mason for TT2
Andy Wardley
abw@cre.canon.co.uk
Sat, 5 Aug 2000 11:58:14 +0100 (BST)
> But I would rather have another solution. With TT2, the content of a
> block can be passed as a parameter to another box. So you could specify
> the specific blocks: (Havn't tested this)
>
> [% content_1 = BLOCK %]
> Some content
> [% END %]
>
> [% content_2 = BLOCK %]
> More content
> [% END %]
>
> [% INCLUDE site
> section = 'example_section'
> content_1 = $content_1
> content_2 = $content_2
> %]
Yep, that's probably the best way to do it at present. In this case,
you're processing the BLOCK and storing the output in 'content_1'.
You can also define a MACRO which will evaluate the BLOCK when it is
inserted (i.e. lazy evaluation).
e.g.
[% BLOCK site %]
[% INCLUDE header
title="My Cool Web Site: $section"
%]
[% x FOREACH x = content %]
[% INCLUDE footer %]
[% END %]
[% MACRO content_1 BLOCK %] ... [% END %]
[% MACRO content_2 INCLUDE something FOREACH x = xstuff %]
[% INCLUDE site
section = 'Section X'
content = [ content_1, content_2 ]
%]
> Have any of you thought of any better way to handle this?
No, not yet. I think there's definately some mileage in being able to
control the process flow by means of a 'super' call, or something
similar. I need to go and dig out some functional programming papers
because I'm sure I've seen something to do with co-routines that might
be relevant here.
A