Generate HTML, XML, plain text with Cheetah
With the Cheetah templating system you can generate any kind of text-based content with Python scripts and Cheetah templates.
Why use a templating system?
Without a templating system, you can use Python code to generate pieces of text like the example e-mail message.But through python code it is hard to see the structure of the e-mail message also the code creates room for error. Developers turn to template systems for these reasons.
Are Python’s built-in templating systems enough?
Python comes with a few built-in templating systems, which work well in simple cases. For a long time, Python had simple template systems that understood formats reminiscent of C’s printf() string formatting:
Cheetah templating system :
Cheetah is inspired by a Javaâ„¢ templating system called Velocity, an improved version of the Webmacro templating system, which is itself an attempt to improve on JavaServer Pages. Cheetah provides a simple language for defining templates that provides basic flow control and object access constructs. It borrows its basic template syntax from Velocity, but adds features that give Cheetah templates access to the convenient constructs of Python.
Features of Cheetah:
- Python for the back end, Cheetah for the front end.
- Cheetah’s core syntax are easy for non-programmers to learn.
- Cheetah make code reuse easy by providing an object-oriented interface to templates.
- Python objects, functions, and other data structures are fully accessible in Cheetah.
- Cheetah provides flow control and error handling.
- Its easy to separate content, graphic design, and program code, but also easy to integrate them.
What you can do with Cheetah :
- You can create reusable components and functions that are accessible to designers.
- can mark out placeholders for content and dynamic components in their templates.
- can reuse and extend existing templates.
- can use the templates that designers have created.
How mature is Cheetah?
Cheetah is stable, production quality, post-beta code. Cheetah’s syntax, semantics and performance have been generally stable .
Reference:
>>Building and filling out templates with Python and Cheetah
>>Cheetah : The python-powered template engine