[Grok-dev] a problem with 'static' and macros

Kevin Smith kevin at mcweekly.com
Tue May 22 20:06:57 EDT 2007

This should work.

<img tal:attributes="src 
string:${context/@@originalmacro/static/myimage.jpg}" />


Martijn Faassen wrote:
> Hi there,
> I have discovered a problem with the combination of the 'static' 
> variable in page templates in combination with macros.
> 'static' is a special variable that Grok makes available to page 
> templates. It makes it easy to refer to static resources in the 
> package's 'static' directory:
> <img tal:attributes="src static/myimage.jpg" />
> Now put the above line in a macro. Now put the macro in one package, 
> and the page template that uses this macro in another package.
> When the second page template is rendered, the 'static' in the macro 
> will reference the static directory in the *new* package, not the 
> package the macro itself is in. This is unexpected, as it disallows 
> the reuse of macros from other packages if they refer to static 
> resources at all.
> We need a solution to this problem. I am at a loss; macros just work 
> this way with names, after all. Is it possible to have a "macro-local" 
> name only dependent on the view of the macro itself? I have no idea 
> how. Anyone got any ideas?
> Regards,
> Martijn
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> http://mail.zope.org/mailman/listinfo/grok-dev

More information about the Grok-dev mailing list