Macros with Grok
This Tutorial applies to:
Any version.
This Tutorial is intended for:
Beginners
All content on one page (useful for printing, presentation mode etc.)
- Introduction Macros are a way to define a chunk of presentation in one template, and share it in others. Changes to the macro are immediately reflected in all of the places, that share it.
- Defining a simple macro In Grok macros are defined in usual views, where the associated page templates contain `metal`-statements to define the desired macros. Macros generally are attributes of the page template wherein they are defined, but to get them rendered, we usually use views.
- Referencing a simple macro How to reference a simple macro?
- Background: how grok.View and macros interact The template attribute and the macro shortcut convention.
- Defining 'all-purpose' macros To define an 'all-purpose' macro, i.e. a macro, that can render objects of (nearly) any type and thus be accessed from any other page template, just set a very general context for your macro view:
- Accessing Zope3 standard macros The standard macros of Zope 3, which render also the default ZMI pages, are accessible under the view-name standard_macros and usually provide slots title, headers and body. It is good style to provide this slots with your homegrown views as well.

