Jinja2 template integration for Morepath
Project description
more.jina2: Jinja2 template integration for Morepath
more.jina2 is an extension for Morepath that adds Jinja2 template support when you use the .jinja2 extension.
For details on the Jinja2 template language see the Jinja2 template designer documentation.
Example usage:
from more.jinja2 import Jinja2App class App(Jinja2App): pass @App.path(path='persons/{name}') class Person(object): def __init__(self, name): self.name = name @App.template_directory() def get_template_directory(): return 'templates' @App.html(model=Person, template='person.jinja2') def person_default(self, request): return {'name': self.name}
and then in person.jinja2 (in the templates subdirectory):
<html> <body> <p>Hello {{name}}!</p> </body> </html>
Note that the Jinja2 documentation uses the .html extension for Jinja2 templates, whereas this extension uses .jinja2 instead.
To control Jinja2 behavior you can define a jinja2 setting section in your app. For instance:
@App.setting_section(section='jinja2') def get_setting_section(): return { 'auto_reload': False, 'autoescape': True, 'extensions': ['jinja2.ext.autoescape'] }
For details on Jinja2 configuration options, consult the Jinja2 API documentation.
CHANGES
0.2 (unreleased)
Nothing changed yet.
0.1 (2015-04-09)
Initial public release.