Skip to main content
CI Status https://coveralls.io/repos/github/morepath/more.jinja2/badge.svg?branch=master https://img.shields.io/pypi/v/more.jinja2.svg https://img.shields.io/pypi/pyversions/more.jinja2.svg

more.jinja2: Jinja2 template integration for Morepath

more.jinja2 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,
    }

For details on Jinja2 configuration options, consult the Jinja2 API documentation.

CHANGES

0.3 (2022-05-29)

  • Apply pyupgrade --py36-plus

  • Use black code formatter.

  • Add support for Python 3.7, 3.8, 3.9 and 3.10.

  • Fix test collection.

  • Drop support for Python 2.7, 3.4, 3.5.

  • Updated the test suite to work with Morepath 0.15.

  • Set up integration with Travis CI. (superseded)

  • Added Tox environments for Python 3.5 and 3.6, PyPy 3, PEP8. (partially superseded)

  • Using Python 3.5 for PEP8 and coverage. (superseded)

  • Clean up meta data.

  • Use GitHub Actions for CI.

  • Fix Jinja2 integration - the autoescape extension was removed as now it is built-in.

0.2 (2015-04-09)

  • Actual release to PyPI.

0.1 (2015-04-09)

  • Initial public release.

Release files for more.jinja2 0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for more.jinja2 0.3
File Size Uploaded
more.jinja2-0.3.tar.gz 7.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for more.jinja2 0.3
File Interpreter ABI Platform
more.jinja2-0.3-py3-none-any.whl Python 3 none any Details

Total release size: 16.3 kB

Release files / more.jinja2-0.3.tar.gz

Download URL more.jinja2-0.3.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
bb4a87972aee309e1c3304f6eaffb982217fb6934fbf165236f0cee80369843b
BLAKE2b-256 checksum
How to use checksums
3aced360f7650a5681733c4f35e6509416d5b0a16d368773088fbc773447b8d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/30.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.8.1 keyring/23.2.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.8.10

Release files / more.jinja2-0.3-py3-none-any.whl

Download URL more.jinja2-0.3-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
78f37d8937188c94384cc8b720e6adeced01c1fa34b4b7abfe0e5022faf58851
BLAKE2b-256 checksum
How to use checksums
bd4d2aede313a7e8a7f1ac5135c8c58cf165c6700c6409c96ef45fbfd8bfe89b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/30.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.8.1 keyring/23.2.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.3 This release

2 release files

0.2

1 release file

0.2.dev0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page