Templating in Python
Templating, and in particular Web templating, involves the presentation of information in a form which is often (but not always) intended to be readable, even attractive, to a human audience. Frequently, templating solutions involve a document (the template) which may look somewhat like the final output but perhaps in a simplified or stylized form, along with some data which must be presented using that template; combining these two things produces the final output which in Web templating is usually (but not always) a Web page of some kind.
Templating Engines
There are many, many different HTML/XML templating packages and modules for Python that provide different feature sets and syntaxes. These libraries usually assume that you know how to write HTML or XML.
The number of templating engines is so great because the mechanisms involved are pretty easy to write in Python, at least for a fairly basic template engine; [http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52305 this recipe from the Python Cookbook] shows how easy it is.
[http://airspeed.pythonconsulting.com/ Airspeed] - Velocity Templates for Python
- ["Castalian"]
- ["Cheetah"]
[#ClearSilver]
[http://www.djangoproject.com/documentation/templates/ Django template system]
Anchor(Elements) [http://www.nthwave.net/elements/ Elements]
[http://www.aerojockey.com/software/hrl HRL] Powerful macro preprocessor for HTML; macros can embed arbitrary Python code
[http://freespace.virgin.net/hamish.sanderson/htmltemplate.html HTMLTemplate]
[http://htmltmpl.sourceforge.net/ htmltmpl]
[http://wsgiarea.pocoo.org/jinja/ Jinja]
[http://kid.lesscode.org/ Kid] -- XML based, compiling template engine
[http://www.myghty.org/ Myghty] inspired by Perl's Mason
- ["pso"]
Anchor(SimpleTAL)[http://www.owlfish.com/software/simpleTAL/ SimpleTAL]
- ["Spyce"]
[http://pytan.com/public/sprite/ Sprite]
[http://www.stringtemplate.org stringtemplate]
- ["teng"]
HTML Shorthand Processors
The libraries in this section implement simpler markup languages that can be automatically converted to HTML. This lets you avoid having to write HTML by hand.
[http://txt2tags.sourceforge.net/ txt2tags]
HTML Generation Packages
These packages are not really templating systems in that they do not typically employ a template document as such to define the form of the output they produce, but they can be useful in applications where it is more convenient to programmatically generate output.
[http://starship.python.net/crew/friedrich/HTMLgen/html/main.html HTMLgen]
[http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/366000 HTMLTags ]
[http://markup.sourceforge.net/ markup ] A light-weight and flexible HTML/XML generator
[http://pyhtmloo.sourceforge.net/ pyhtmloo ] pyhtmloo is a library that allows python developers to use HTML code like any other python objects.
Static Website Generators
Static website generators are more than templating engines in that they create the whole site structure, not just individual files. While templating is an important part of their function, determining the site structure and incorporating structural information in the output (for example to automatically generate navigational elements) is what really makes a static website generator a useful tool.
[http://www.ivy.fr/tahchee/ tahchee] - ["Cheetah"]-based static web site generator
[http://www.owlfish.com/software/PubTal/ PubTal] - [#SimpleTAL]-based static web site generator
- [#Elements]
[http://www.voidspace.org.uk/python/rest2web/] - Generates Websites from ReST contents
Java Templating Engines
The following templating engines are accessible or usable via Jython:
[http://freemarker.org/index.html FreeMarker] (with Jython data binding)
[http://java.sun.com/products/jsp Java Server Pages, JSP]
CPython-accessible C Templating Engines
Anchor(ClearSilver) ClearSilver (HTML generation)