Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

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 (2015-04-09)

  • Actual release to PyPI.

0.1 (2015-04-09)

  • Initial public release.
Release History

Release History

This version
History Node

0.2

History Node

0.2.dev0

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
more.jinja2-0.2.tar.gz (6.5 kB) Copy SHA256 Checksum SHA256 Source Apr 9, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting