Skip to content

Pitmairen/jinja-simplesyntax

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

jinja-simplesyntax

Overview

This extension to jinja make it possible to close tags with just "end" instead of endif, endfor and so on. It can be mixed with normal end tags.

It also works with line statements.

Usage

from jinja2 import Environment
from jinja_simplesyntax import SimpleSyntaxExtension

env = Environment(
        line_statement_prefix='%:'
        extensions=[SimpleSyntaxExtension])

Example

{% for i in range(10): %}
    {% if i == 0 %}
        First
    {% else %}
        {{ i }}
    {% end %}
{% end %}

With line statements its also possible to use inline content like this:

%:block title | This is the title

%:if True | Yes it's true

This becomes:

{% block title %}This is the title{% endblock %}

{% if True %}Yes it's true{% endif %}

About

Simplifies the syntax of jinja2 templates a little bit

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages