Skip to main content

No project description provided

Project description

Muffin-Jinja2 – Jinja2 template engine for Muffin framework.

Build Status http://img.shields.io/pypi/v/muffin-jinja2.svg?style=flat-square http://img.shields.io/pypi/dm/muffin-jinja2.svg?style=flat-square Donate

Requirements

  • python >= 3.3

Installation

Muffin-Jinja2 should be installed using pip:

pip install muffin-jinja2

Usage

Add muffin_jinja2 to PLUGINS in your Muffin Application configuration.

Options

JINJA2_AUTO_RELOAD – Auto reload changed templates (False)

JINJA2_CACHE_SIZE – Cache templates (50)

JINJA2_EXTENSIONS – Enable Jinja2 Extensions (None)

JINJA2_LOADER – Template loader (FileSystemLoader)

JINJA2_ENCODING – Default encoding for file loader

JINJA2_TEMPLATE_FOLDERS – List of template folders ([‘templates’])

Views

# Register custom context processor
# could be a function/coroutine
@app.ps.jinja2.context_processor
def custom_context():
    return { 'VAR': 'VALUE' }

# Register a function into global context
@app.ps.jinja2.register
def sum(a, b):
    return a + b

# Register a function with a different name
@app.ps.jinja2.register('div')
def mod(a, b):
    return a // b

# Register a filter
@app.ps.jinja2.filter
def test(value, a, b=None):
    return a if value else b

# Register a filter with a different name
@app.ps.jinja2.filter('bool')
def boolean(value):
    return bool(value)

@app.register('/')
def index(request):
    """ Check for user is admin. """
    local_context = {'key': 'value'}
    return app.ps.jinja2.render('index.html', **local_context)

Bug tracker

If you have any suggestions, bug reports or annoyances please report them to the issue tracker at https://github.com/klen/muffin-jinja2/issues

Contributing

Development of Muffin-Jinja2 happens at: https://github.com/klen/muffin-jinja2

Contributors

  • klen (Kirill Klenov)

License

Licensed under a MIT license.

Project details


Download files

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

Source Distribution

muffin-jinja2-0.2.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

muffin_jinja2-0.2.0-py2.py3-none-any.whl (5.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file muffin-jinja2-0.2.0.tar.gz.

File metadata

  • Download URL: muffin-jinja2-0.2.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.27.0 CPython/3.6.3

File hashes

Hashes for muffin-jinja2-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f2552c116d2961123d56b5214d87d7b545d24b214da8780818f4542c5f94b4da
MD5 c38c05314e7abb489d1d9d65ae990be9
BLAKE2b-256 556335c20796fbf5e60b1ca19ee0743eaf905f5b27c7fea249e18749c795762e

See more details on using hashes here.

File details

Details for the file muffin_jinja2-0.2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: muffin_jinja2-0.2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.27.0 CPython/3.6.3

File hashes

Hashes for muffin_jinja2-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 470665dcc969a77c32c9e4c6fb8ec562dbbcb36314c95c608730f0a4c79af4c4
MD5 d1cbfb75ab20245e93ebd967ff65d03f
BLAKE2b-256 644c0ca973f86e2989394f7158d35c5a6ffe8f5c00c0e8e5a0c7529b5292c6a1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page