How do I use templates?

Asked by Eleanor Berger

How do I use Templator, the built-in templating package?

Question information

English Edit question
For: Edit question
No assignee Edit question
Solved by:
Eleanor Berger
Last query:
Last reply:
Revision history for this message
Best Eleanor Berger (intellectronica) said :

For basic doc and some code snippets, see

To display your page from inside a app, just do:

    homepage = template.Template(open("homepage.tmpl").read())
    print homepage()

Alternatively, you can use the render object to access all of your templates:

    render = web.render('templates/') # Render can be a global object - it will optionally cache templates

    print render.my_template() # the method name corresponds to the name of a template file