rhino.ext.jinja2
This module contains a JinjaRenderer
class that can be used to add a renderer property to the context that renders Jinja2 templates.
This extension requires the Jinja2 module to be installed:
$ pip install jinja2
Example usage:
from rhino import Mapper, get
from rhino.ext.jinja2 import JinjaRenderer
app = rhino.Mapper()
app.add_ctx_property('render_template', JinjaRenderer('./templates'))
@get
def index(request, ctx):
return ctx.render_template('index.html', greeting="hello, world!")
app.add('/', index)
class JinjaRenderer
__init__(directory=None, autoescape=True, **env_args)