From fa446e1f12547c8baa943edb102c34d7747e5724 Mon Sep 17 00:00:00 2001 From: "Michael R. Bernstein" Date: Tue, 2 Dec 2014 09:50:02 -0600 Subject: [PATCH] Added basic section on Chameleon --- docs/scenarios/web.rst | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/docs/scenarios/web.rst b/docs/scenarios/web.rst index 4d7551e..7fa1885 100644 --- a/docs/scenarios/web.rst +++ b/docs/scenarios/web.rst @@ -414,7 +414,44 @@ into the corresponding block in the :file:`base.html` page.

{% endblock %} +Chameleon +--------- +`Chameleon `_ is a template engine which is similar to +the Chameleon is an HTML/XML template engine for Python. +It’s designed to generate the document output of a web application, typically HTML markup or XML. + +The language used is page templates, originally a Zope invention [1], but available here as a standalone library that you can use in any script or application running Python 2.5 and up (including 3.x and pypy). It comes with a set of new features, too. + +The template engine compiles templates into Python byte-code and is optimized for speed. For a complex template language, the performance is very good. + +Here is an example of a template tags in Chameloen: + +The *page templates* language is used within your document structure +as special element attributes and text markup. Using a set of simple +language constructs, you control the document flow, element +repetition, text replacement and translation. + +.. note:: If you've used page templates in a Zope environment previously, note that Chameleon uses Python as the default expression language (instead of *path* expressions). + +The basic language (known as the *template attribute language* or TAL) +is simple enough to grasp from an example: + +.. code-block:: html + + + +

Hello, ${'world'}!

+ + + + +
+ ${row.capitalize()} ${col} +
+ + + .. rubric:: References .. [1] `The mod_python project is now officially dead `_