On Fri, Mar 4, 2011 at 3:19 PM, drebbin <[email protected]> wrote:
> Sorry, It seems to be the other way round:
> layouts/default.pt:
> <html xmlns="http://www.w3.org/1999/xhtml";
>    xmlns:tal="http://xml.zope.org/namespaces/tal";
>    xmlns:metal="http://xml.zope.org/namespaces/metal";>
> <span metal:define-macro="content">
>  <div id="content">
>   <span metal:define-slot="content">content</span>
>  </div>
> </span>
> <p>misc in default</p>
> </html>
> index.pt:
>  <html xmlns="http://www.w3.org/1999/xhtml";
>        xmlns:tal="http://xml.zope.org/namespaces/tal";
>        xmlns:metal="http://xml.zope.org/namespaces/metal";>
>    <span metal:use-macro="default.macros['content']">
>      <span metal:fill-slot="content">Hello from ZPT</span>
>    </span>
>    <p>misc in index</p>
>  </html>
> The rendered page shows "Hello from ZPT" and "misc in index" ("misc in
> default" is ignored). Which reflects exactly what the code states.
> So one would have to invert the calling of the templates. Instead declaring
> "index.pt" as the view's renderer, I'd declare "layouts/default.pt". And the
> view provides template "index.pt" in the data, e.g. as key "content".
> Can that be?

In your layout, use define-macro on the HTML element:

<html xmlns="http://www.w3.org/1999/xhtml";
   xmlns:tal="http://xml.zope.org/namespaces/tal";
   xmlns:metal="http://xml.zope.org/namespaces/metal";
   define-macro="content">
 <div id="content">
  <span metal:define-slot="content">content</span>
 </div>
<p>misc in default</p>
</html>

Same with use-macro in your index.pt:

 <html xmlns="http://www.w3.org/1999/xhtml";
       xmlns:tal="http://xml.zope.org/namespaces/tal";
       xmlns:metal="http://xml.zope.org/namespaces/metal";
       metal:use-macro="default.macros['content']">
     <span metal:fill-slot="content">Hello from ZPT</span>
     <p>misc in index</p>
 </html>

The resulting HTML will be all of layout.pt, with only the "content"
slot replaced.

HTH,
Daniel


-- 
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