Python vs PHP
Valentino Volonghi aka Dialtone
dialtone.##NOSPAM#$#$$# at gmail.com
Mon Oct 25 11:50:44 EDT 2004
Max M <maxm at mxm.dk> wrote:
> Zope Page Templates has a far better approach to this imho. Where you
> define reusable markup in a macro.
>
> The box could then be defined with title and content slots like::
>
>
> <div metal:define-macro="box">
> <h5><metal:block define-slot="title">The title</metal:block></h5>
> <metal:block define-slot="content"/>This is example
> content</metal:block>
> </div>
>
> [snip]
>
> This approach makes it relatively easy to reuse markup as well as logic.
> It is possible use arbitrarily complex markups as "parameters" to the
> slots in the template. Wich makes it very nice for larger systems.
Which with Nevow is perfectly natural since you can do:
<div nevow:render="content">
<nevow:slot name="content" />
</div>
and then in the code:
def render_content(self, ctx, data):
ctx.tag.fillSlots('content', My_Fragment())
return ctx.tag
Just like I've done in weever (on berlios) where there is a main file that
defines the base class for all the pages and requires a content fragment as
argument with which it will fill the empty slot to render the whole page.
Then I subclass the main page class to give the behaviour I need, and then I
pass the content 'page' to have it rendered in the output.
--
Valentino Volonghi aka Dialtone
Now running FreeBSD 5.3-beta7
Blog: http://vvolonghi.blogspot.com
More information about the Python-list
mailing list