Using Jinja in TG2ΒΆ

This means you’ll write expose statements with path strings:

@expose('index.html')

The standard start location is assumed to be your templates directiory, so if you have admin page templates under an admin directory inside templates you’d do:

@expose('/admin/index.html')

Jinja provides yet another template rendering solution for TurboGears, but it has a couple of advantages for specific situations:

TurboGears allows you to setup and use jinja templates by simply adding it to the list of renderers to prepare in base_config:

base_config.renderers.append('jinja')

You can also set it as the default renderer by setting:

base_config.default_renderer = "jinja"

The Jinja docs cover template syntax very well, so we’ll not repeat it here, but take a look here:

http://jinja.pocoo.org/2/documentation/templates

Previous topic

Using Mako in TG2

Next topic

Working with SQLAlchemy and your data model

This Page