Jinja (Template engine)
From Wikipedia, the free encyclopedia
Jinja is a template engine that uses the Python programming language.
It is designed to strike a balance between content and application logic, which means that Jinja doesn't provide if conditions with more than one term...
Jinja doesn't compile templates like Cheetah does, but provides a caching system which saves the internal nodelist to a file.
It also ships an easy to user filter system like Smarty does, similar to the Pipeline system of Unix.
[edit] Example
Here is a small example of the Jinja template:
from jinja import Template, Context, StringLoader t = ''' <html> <head><title>{{ variable|search "a", "e" }}</title></head> <body> {% for item in list %} {{ item }}{% if not loop.last %},{% endif %} {% endfor %} </body> </html> ''' t = Template(t, StringLoader()) c = Context({ 'variable': 'Value', 'list': [1, 2, 3, 4, 5, 6] }) print t.render(c)