I am using Pyramid 1.3 and their templates written in Chameleon. As different pages or templates might need a global stylesheet change per page, I would like to be able to redefine classes of the body tag on the page (of course, I would prefer to do this from the templates).
<body class="${global_variable_or_something_else}"></body>
What I have tried:
- Using tal:define="global body_class" from the submacros. Doesn't work.
- I have tried to use
<metal:div metal:define-slot="vars">...variable definition...</metal:div>
and<metal:div metal:fill-slot="vars">...redefinition...</metal:div>
, and redefining the variables in the submacros. It does work, but what if I have several variable definitions in the parent template and I need to redefine only one?
Is there a good way of doing this better with METAL?
Globals in page templates, like globals in Python, can be overridden. So you do the following instead:
Then use a
metal:fill-slot
to provide overrides; you can override as few or as many of the variables as you want: