1.12 web.template -- For the easy display of data as HTML/XML

The web.template module currently only provides one function, pasrse(), used to parse a template.

parse( type='python', dict=None [,file=None][,template=None][,useCompiled='auto'][,swapTemplatePaths=None])
Simple wrapper method to load and parse a template from the options given.
type
The type of template to parse. Can be 'python', 'cheetah', 'xyaptu' or 'dreamweaverMX'. A 'python' template is a string using the dictionary filling format.
dict
A dictionary of values used to fill the template
file
The file containing the template. If not specified or None, template must be specified.
template
The template as a string. If not specified or None, file must be specified.
useCompiled
Only used for Cheetah. Specifies whether or not a compiled version of the template should be used.
swapTemplatePaths
Only used for DreamweaverMX. If None nothing is done. Otherwise can be set to (oldPath, newPath) to swap paths in the template itself before the parsing is done.

Simple example:

>>> import web.template
>>> print web.template.parse(dict={'w':'World!'}, template="Hello %(w)s")
Hello World!

This is the same as doing this in Python:

>>> print "Hello %(w)s"%{'w':'World!'}
Hello World!



Subsections