Combining renderers to reduce code repetition.

I'm looking for a way to ensure that I don't have to repeat boilerplate 
HTML in my renderers. So far the best that I can find is something along 
these lines:

@view_config(route_name='home', renderer='base.mako'):
    body_text = render("home.mako")
    return {"body": body_text, "title": "Welcome"}

And this should work assuming the following .mako files:

base.mako...


<!DOCTYPE html>
<html>
    <head>
        <title>${title}</title>
    </head>
    <body>
        ${body}
    </body>
</html>

home.mako...


<h1>Welcome!</h1>


I've looked around for other ways to compose multiple renderer files into a 
single output, but this is the only solution I've been able to come up 
with. Is there a better way to do this?

Please, if there's anything I can do to clarify my question let me know.

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.

Reply via email to