[Twisted-web] Nested Nevow templates

Valentino Volonghi dialtone at gmail.com
Thu Nov 4 15:17:49 MST 2004

On Thu, 04 Nov 2004 13:33:10 -0800, Erik Swan <erik at splunktechnology.com> wrote:
> Everyone,
> I'm somewhat new to Nevow and have a simple question - btw, it maybe
> already possible and i missed the man page...

Actually... Even a poor man page would be welcome these days :)
> My question centers around the best way to have nested templates - that
> is i'd like a directive that would function as an include and all the
> appropriate Nevow render code get executed automatically. That way our
> designer can build a header, footer, sidebars, and other html components
> as separate files and the main template just "includes" as appropriate.
> Something like
>   <nevow:include name="blah.html">

Nevow provides Fragments that are mostly like Page objects but could
be rendered inside another Page like they were simple tags or strings
(that fill slots).

<nevow:invisible nevow:render="content">
    <nevow:slot name="content" />

And in the code side:

    def render_content(self, ctx, data):
        ctx.tag.fillSlots('content', MyFragment())
        return ctx.tag

class MyFragment(rend.Fragment):
    docFactory = loaders.xmlfile('some_partial_html.html', ignoreDocType=True)

I also suggest putting all the html from the partial html inside a
<nevow:invisible> tag.

I've implemented such a thing in weever:

Here is the source view from svn, in the templates directory you will
find all the templates while under web all the logic that handles the
composition (main.py is the most important file)


Valentino Volonghi aka Dialtone
Now running FreeBSD 5.3-beta6
Blog: http://vvolonghi.blogspot.com
Home Page: http://xoomer.virgilio.it/dialtone/

More information about the Twisted-web mailing list