[Zope] macro context confusion

Cliff Ford Cliff.Ford at ed.ac.uk
Tue Oct 12 11:14:25 EDT 2004


I don't know if this helps, but here is my master template style line:

<link rel="stylesheet" href="a.css" tal:attributes="href here/siteStyle" 
type="text/css">

so in any folder, the local style is in an object called siteStyle. I 
might have one style sheet in /siteStyle and another style in 
/computers/siteStyle.

I guess your problem is that the macro template is in the / container so 
it is just plugging in /style. Use here instead of container and it will 
plug in the first inherited style.

Cliff

David Clymer wrote:
> Is there a way make a macro get expanded within the context in which it
> is called (maybe it always does, and I'm just confused)? For example,
> I've got the following slot defined in /standard_template.pt
> 
>   <head>
>     <metal:block define-slot="head">
>     <title tal:content="template/title">The Title</title>
>     <link rel="stylesheet" type="text/css"
> href="/stylesheets/default.css" tal:attributes="href container/style" />
>     </metal:block>
>   </head>
> 
> and call the encompasing macro in a different directory/file:
> /computers/index_html
> 
> the variable "container/style" is defined in the / directory as
> "/stylesheets/default.css" and in /computers/ as
> "/stylesheets/computers.css"
> 
> when I test /computers/index_html, the stylesheet remains
> /stylesheets/default.css, even when I remove the explicit href="..." and
> leave only tal:attributes=.... in the macro. What I'm assuming here is
> that the macro must be expanded in the container that the macro is
> defined in rather than the container that it is being called in. That or
> i'm doing something wrong.
> 
> What I'd like is to have a single template that can be used to generate
> a page with a different stylesheet depending on where it lies in the
> site folder hierarchy. Is there a better way to do this, or at least a
> way to fix what I've got?
> 
> -davidc
> 
> _______________________________________________
> Zope maillist  -  Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )


More information about the Zope mailing list