Skip to main content

Haml-ish syntax for jinja2 templates

Project description

Overview

This extension to jinja makes it possible to use a haml-ish syntax for your jinja templates. It is implemented as a preprocessor and so it runs only the first time your template is parsed. So it will not affect the performance of your templates except for the first run.

Forked from Pitmairen/hamlish-jinja

Usage

Install

You can install the latest version with pip

pip install git+https://git.barkshark.xyz/barkshark/hamlish-jinja

or

pip install jinja2-haml

Basic Usage

To use this extension you just need to add it to you jinja environment and use “.haml”, “.jhaml”, or “.jaml” as an extension for your templates.

from jinja2 import Environment
from hamlish_jinja import HamlishExtension

env = Environment(extensions = [HamlishExtension])

Environment

Added in version 0.2.0

The environment gets extended with a new method hamlish_from_string which works the same as the standard env.from_string method, but renders the template with the hamlish preprocessor.

tpl = '''
%div
    %p
        test
'''

env.hamlish_from_string(tpl).render()

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

Jinja2-Haml-0.3.5.tar.gz (20.6 kB view hashes)

Uploaded Source

Built Distribution

Jinja2_Haml-0.3.5-py2.py3-none-any.whl (16.5 kB view hashes)

Uploaded Python 2 Python 3

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