[Grok-dev] Accessing a METAL template from another template
Uli Fouquet
uli at gnufix.de
Tue Jan 15 09:34:55 EST 2008
Hi Sebastian,
Sebastian Ware wrote:
> Unfortunately it only covers accessing a template from the current
> view. This page explains what I am trying to do:
>
> http://www.zopelabs.com/cookbook/1053557445
The master template in the macros tutorial Daniel pointed to, is a
template for instances of ``Master`` view, which is not your 'current'
view. Please review the 'all-purpose-macros' section.
There is no limit in setting up 'masters' of 'masters'. Given you have a
main template 'master.pt', which is bound to a view 'Master' (as done in
the tutorial)::
class Master(grok.View):
grok.context(Interface)
then you can define::
class Monkeybutter(grok.View):
grok.context(Interface) # Same as in the `Master` class
or, for short::
class Monkeybutter(Master):
pass
Add a template ``monkeybutter.pt`` in `app_templates/` which references
the old master template as `context/@@master/macros/master` and
reference the new fascade macros from, for example, indext.pt like
this::
context/@@monkeybutter/macros/master
simply replacing '@@master' by '@@monkeybutter'.
I assumed, this would be made clear in the tutorial. Maybe I should
explain it more in-depth.
BTW: In the macros-tutorial all macro references are shown as::
context/@@<viewname>/<macroname>
This is now deprecated and you should use instead::
context/@@<viewname>/macros/<macroname>
(with explicit 'macros/'). I will update this shortly.
Hope that helps,
--
Uli
More information about the Grok-dev
mailing list