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.1.1.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

muffin_jinja2-0.1.1-py2.py3-none-any.whl (6.4 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

File hashes

Hashes for muffin-jinja2-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f766e9c3bd1e1d9bd46a95fdaa2fcbfbe1214439640e3ab1722f181b508227dc
MD5 b826b7ff57b79859a86c2250f4171de4
BLAKE2b-256 8b8532b056ee4e4cd426861dfa95024d524b24c69f7c5b0705a019830d968d09

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for muffin_jinja2-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9035fa0b2e524870ef10d2b0985bc6ffccd7da80297e3f05e7f1e7bd602fe842
MD5 7b8d48c6282812771f1249f6093927da
BLAKE2b-256 19f4694e9ac30fe00bba0fde52cae9591570076eae7e2693749034c74f5d41e7

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