[Product-Developers] Call a macro with python ?
Hedley Roos
hedley at upfrontsystems.co.za
Fri Feb 22 09:08:48 UTC 2008
yleclanche wrote:
> Hello,
>
> Is it possible to call a macro in python ? This call should returns me the
> html code generated.
>
>
> Thanks.
Sure it is. You'll need an intermediary page template though. I call
mine macro_renderer.pt
<metal:block use-macro="here/global_defines/macros/defines" />
<div metal:use-macro="python:path('%s/macros/%s' % (thetemplate,
macro))" />
And you call it like this:
html = context.macro_renderer.pt_render(
extra_context = {'thetemplate':'context/page_template_with_macros',
'macro':'the_macro_i_want_to_call',
}
)
Any other variable you want to be in scope for the macro you'll have to
pass in the extra_content dictionary.
Hedley
More information about the Product-Developers
mailing list