Thanks a lot for for the fast reply Andy...
On Wed, 2003-06-04 at 11:45, Andy Wardley wrote:
> alex wrote:
> > [% website.process('inc/blocks') %]
> >
> > Is that possible?
>
> If you're asking if it's possible to include a BLOCK defined in
> another template, then yes it is, if you set the EXPOSE_BLOCKS option.
>
> It may not be documented (yet), but it does the trick.
I don't understand what EXPOSE_BLOCKS does, so I'll try to explain
myself further.
We have fifty or so websites using template toolkit. They share the
same template toolkit object with the same include path of
'/space/templates'. So that they can include other templates relative
to their subdirectory from the template root, they define a view like
this:
[% VIEW website
prefix = 'Playlouder/docs/' %]
[% END %]
So then to include Playlouder/docs/foo/header, we can do this:
[% website.include('foo/header') %]
This is really handy, because it means that the templates can be copied
between websites and they will still work, without any paths having to
be changed.
Now I don't understand the effect of the EXPOSE_BLOCKS option you
mention. When I do this:
[% PROCESS Playlouder/docs/include/fancy_blocks %]
[% INCLUDE blue_fish %]
and fancy_blocks contains this:
[% BLOCK blue_fish %]BLUE FISHES[% END %]
The block is included, regardless of whether EXPOSE_BLOCKS is set.
However, this doesn't work:
[% INCLUDE Playlouder/docs/include/fancy_blocks %]
[% INCLUDE blue_fish %]
... and still doesn't work if EXPOSE_BLOCKS is set. This is expected;
as I understand it, INCLUDE forces a localised namespace, I expect that
to include BLOCK definitions as well as variables.
So... I want to be able to ask a view object to PROCESS a template (or
block) rather than INCLUDE it. You're right in assuming that I'm trying
to bring in blocks from other templates, but I'm not sure how the
EXPOSE_BLOCKS option works, and how it could help me in this case.
I hope that's clear, and that what I'm trying to do is reasonably
sane...
cheers
alex
--
alex <[EMAIL PROTECTED]>
_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates