On Thu, Jun 23, 2011 at 10:02 AM, Malthe Borch <[email protected]> wrote:
> On 22 June 2011 23:13, Bruce Wade <[email protected]> wrote:
>> I have used Mako with pylons, now I am trying to rap my head around
>> chameleon for pyramid. How do we keep our templates DRY using chameleon?
>> Does it support template inheritance? (Where you can have a base file and
>> just include it into the other template files)
>
> Yes.
>
> ZPT (the language) includes a set of attributes to define and use
> macros – these are together known as METAL.
>
> See:
>
> http://chameleon.repoze.org/docs/latest/reference.html#metal
>
> This system works well –– Plone uses it extensively.
>
The problem is that you can't call a macro directly from template in
pyramid. You need to add something like this in your python code
before rendering:
macros = get_renderer('mypackage:master.pt').implementation()
I would be cool if we can do something like:
<html metal:use-macro="mypackage:master.pt/macros/master" />
Don't know if this can be done easily... Maybe with a small python
helper added to template's context:
<html metal:use-macro="macros('mypackage:master.pt')['master']" />
Just a thought. Maybe the recommended way is to use a BeforeRender
event to add macros to context. But actually there is no recommended
way AFAIK :)
> It would be nice to have an introduction that goes beyond this
> reference. It might be out there – somewhere on the internet.
>
> \malthe
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/pylons-discuss?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.