- Jinja (Template engine)
Jinja is a
template engine for the Python programming language. It's similar to the Django template engine but provides python like expressions while ensuring that the templates are evaluated in a sandbox. It's a text based template language thus it can be used to generate any markup as well as sourcecode. It's licensed under a BSD License. Unlike Django it's not possible to add custom tags because Jinja templates are compiled into cacheable python bytecode on the fly.It also ships an easy to use filter system like
Smarty does, similar to the Pipeline system ofUnix .Example
Here is a small example of a template:
from jinja import from_stringtmpl = from_string(u"'
variable|escape {% for item in list %} item {% if not loop.last %},{% endif %}{% endfor %}"')print tmpl.render( variable='Value with
data', list= [1, 2, 3, 4, 5, 6] ) External links
* [http://jinja.pocoo.org/ Jinja website]
Wikimedia Foundation. 2010.