On Fri, Mar 4, 2011 at 2:03 PM, drebbin <[email protected]> wrote:
> Hmm. This bears several *ouch*:
> 1. The doc states, to reference a macro in a template that is defined in
> another template, the view has to put the referenced template into the
> available variables. Then, the view is involved in the page layout, which I
> dislike. The template should specify its layout and the view should only
> provide the data.

What I do is I wrap template variables into a TemplateAPI object and
send it along to every template.  You can also use the IBeforeRender
event to provide globals to the template, such as your master
template.

> 2. Besides looking cumbersome with that (define|use) (macro|slot) stuff,
> what I had in mind would render illegal XML. The inherited layout template
> should contain the complete page structure, including the opening HTML tag
> and the doctype. Afaiu all content I want to reference elsewhere has to be
> enclosed in a define-macro block. So the needed doctype and HTML tag had to
> be inside the define-macro block as well. But I cannot use the define-macro
> attribute, because its namespace is defined inside that block.

Look at the example in the docs that you linked to.  When you
use-macro, you'll get the whole layout page and override only those
blocks that you're interested in with fill-slot.  Anything in the
inheriting template that's not inside fill-slot will be ignored.

> In mako this looks intuitive and easy:
> templates/layouts/default.mak:
> <!DOCTYPE html>
> <html>
> <body>${next.body()}</body>
> </html>
> templates/index.mak
> <%inherit file="layouts/default.mak" />
> <p>blah</p>
> Or am I missing sth?

This looks indeed more intuitive than metal for what you're looking for.


-- 
Daniel Nouri
http://danielnouri.org

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to