[Zope] Re: Filling nested METAL macro slots with ZSQL items

Evan Simpson evan@4-am.com
Thu, 15 Aug 2002 11:25:59 -0500


Eric Walstad wrote:
> <html metal:use-macro="here/master.html/macros/portfolio">
>   <head>
>     <title tal:content="template/title">The Title</title>
>   </head>
>   <body>
>     <span tal:define="project python: container.sqlProjectDataById[p_id]">
>     <span metal:fill-slot="description" 
> tal:content="project/description">Description goes here</span>

This bit looks problematic to me.  Your 'tal:define' is in the macro 
use, but not in a slot, so it's going to get stomped on unless it also 
occurs in the macro definition.  You could do either of the following, 
if that's the case:

<tal:x define="global project python:container.sqlProjectDataById[p_id]" />
<html metal:use-macro="here/master.html/macros/portfolio">
   <head>
     <title tal:content="template/title">The Title</title>
   </head>
   <body>
     <span metal:fill-slot="description"
tal:content="project/description">Description goes here</span>

..or..

<html metal:use-macro="here/master.html/macros/portfolio">
   <head>
     <title tal:content="template/title">The Title</title>
   </head>
   <body>
     <span metal:fill-slot="description"
tal:define="global project python:container.sqlProjectDataById[p_id]"
tal:content="project/description">Description goes here</span>

In either case, the 'global' will ensure that the variable is defined 
through all of the slots.

Cheers,

Evan @ 4-am