Jinja (Template engine)

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 of Unix.

Example

Here is a small example of a template:

from jinja import from_string

tmpl = from_string(u"'<small> variable|escape </small>{% 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.

Игры ⚽ Поможем написать реферат

Look at other dictionaries:

  • Template Engine — Dieser Artikel wurde aufgrund von inhaltlichen Mängeln auf der Qualitätssicherungsseite der Redaktion Informatik eingetragen. Dies geschieht, um die Qualität der Artikel aus dem Themengebiet Informatik auf ein akzeptables Niveau zu bringen. Hilf… …   Deutsch Wikipedia

  • Jinja — may be:* Jinja, Uganda, a city in Uganda close to the source of the Nile River * Jinja District, the district in Uganda named after the above city * Jinja (Shinto), a Shinto shrine * Jinja (Template engine), a Template engine …   Wikipedia

  • Comparison of code generation tools — This article compares variable metamodel code generation tools[clarification needed]. Fixed metamodel code generation tools, such as UML tools, are excluded (see List of UML tools). Name Creator OS First public release Latest stable version… …   Wikipedia

  • Templatesprache — Eine Template Engine (von engl. Vorlage und Antrieb, Motor) ist eine Software, die eine Datei (das Template) verarbeitet, und bestimmte Platzhalter darin mit jeweils aktuellen Inhalten füllt. Die Bezeichnungen Templateklasse und Templatesystem… …   Deutsch Wikipedia

  • Templatesystem — Eine Template Engine (von engl. Vorlage und Antrieb, Motor) ist eine Software, die eine Datei (das Template) verarbeitet, und bestimmte Platzhalter darin mit jeweils aktuellen Inhalten füllt. Die Bezeichnungen Templateklasse und Templatesystem… …   Deutsch Wikipedia

  • CherryPy — Developer(s) CherryPy team Stable release 3.2.0 / February 25, 2011; 8 months ago (2011 02 25) Written in Python …   Wikipedia

  • TurboGears — Infobox Software name = TurboGears developer = [http://www.blueskyonmars.com/ Kevin Dangoor] et al. latest release version = 1.0.7 latest release date = September 15, 2008 programming language = Python operating system = Cross platform genre =… …   Wikipedia

  • Django — Тип веб фреймворк Автор Lawrence Journal World …   Википедия

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”