Skip to content

A basic (and heavily jinja inspired) python template engine

License

Notifications You must be signed in to change notification settings

areebbeigh/minja

Folders and files

NameName
Last commit message
Last commit date

Latest commit

698704c · Sep 19, 2020

History

9 Commits
Oct 24, 2019
Nov 13, 2019
Nov 15, 2019
Sep 19, 2020
Nov 13, 2019
Nov 28, 2019
Nov 26, 2019
Nov 26, 2019
Nov 26, 2019
Nov 26, 2019
Nov 28, 2019
Nov 26, 2019
Nov 28, 2019
Nov 28, 2019
Oct 24, 2019
Nov 20, 2019
Nov 26, 2019

Repository files navigation

minja

[ Work in progress ]

A basic (and heavily jinja inspired) python template engine intended to teach myself basic compiler design.

from minja import Template

template = '''{{hello}}
{% if 1 < 2 %}
    <b>{{hello2}}</b>
    {{func('bye')}}
    heya
{% endif %}
{% with x, y = (1, 'test') %}
    {{x}}
{% endwith %}
{% block test %}
    {% for i in get_list() %}
        {{i}}
    {% endfor %}
{% endblock %}
'''

def f():
    return [1,2,3,4]

t = Template(template, autoescape=True)
print(
    t.render(
        hello="Hey there!",
        hello2="<h1>Sup? I'm escaped</h1>",
        get_list=f,
        func=lambda x: x))

Output:

Hey there!

    &lt;h1&gt;Sup? I&#39;m escaped&lt;/h1&gt;
    <b>bye</b>
    heya


    1


    
        1
    
        2
    
        3
    
        4

About

A basic (and heavily jinja inspired) python template engine

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages