A fast and lightweight Python template engine
Python
Switch branches/tags
Nothing to show
Latest commit e828042 Nov 14, 2013 @avelino avelino Merge pull request #6 from xuhdev/as-module
Add __init__.py so that the dir can be used as a module.

README.rst

Quik

Build Status - Travis CI

A fast and lightweight Python template engine

Features

  • Easy to use.
  • High performance.
  • Autoescaping.
  • Template inheritance.
  • Supports native python expressions.

Install

pip install quik

or developer mode:

pip install -r git+https://github.com/avelino/quik.git#egg=quik

Nutshell

Here a small example of a Quik template

<ul>
    #for @user in @users:
        #if @user.age > 18:
        <li><a href="@user.url">@user.username</a></li>
        #end
    #end
</ul>

Use It

Render via template:

from quik import FileLoader

loader = FileLoader('html')
template = loader.load_template('index.html')
print template.render({'author': 'Thiago Avelino'},
                      loader=loader).encode('utf-8')

Render via string:

from quik import Template

temp = Template("""
<ul>
    #for @user in @users:
        #if @user.age > 18:
        <li><a href="@user.url">@user.username</a></li>
        #end
    #end
</ul>
""")

users = [
    {'username': 'foo', 'url': 'http://...', 'age': 25},
    {'username': 'bar', 'url': 'https://...', 'age': 18}]

print temp.render(locals())