Skip to content

Commit fa446e1

Browse files
committed
Added basic section on Chameleon
1 parent ec1cbf4 commit fa446e1

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

docs/scenarios/web.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,44 @@ into the corresponding block in the :file:`base.html` page.
414414
</p>
415415
{% endblock %}
416416

417+
Chameleon
418+
---------
419+
`Chameleon <https://chameleon.readthedocs.org/>`_ is a template engine which is similar to
420+
the Chameleon is an HTML/XML template engine for Python.
417421

422+
It’s designed to generate the document output of a web application, typically HTML markup or XML.
423+
424+
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.
425+
426+
The template engine compiles templates into Python byte-code and is optimized for speed. For a complex template language, the performance is very good.
427+
428+
Here is an example of a template tags in Chameloen:
429+
430+
The *page templates* language is used within your document structure
431+
as special element attributes and text markup. Using a set of simple
432+
language constructs, you control the document flow, element
433+
repetition, text replacement and translation.
434+
435+
.. 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).
436+
437+
The basic language (known as the *template attribute language* or TAL)
438+
is simple enough to grasp from an example:
439+
440+
.. code-block:: html
441+
442+
<html>
443+
<body>
444+
<h1>Hello, ${'world'}!</h1>
445+
<table>
446+
<tr tal:repeat="row 'apple', 'banana', 'pineapple'">
447+
<td tal:repeat="col 'juice', 'muffin', 'pie'">
448+
${row.capitalize()} ${col}
449+
</td>
450+
</tr>
451+
</table>
452+
</body>
453+
</html>
454+
418455
.. rubric:: References
419456

420457
.. [1] `The mod_python project is now officially dead <http://blog.dscpl.com.au/2010/06/modpython-project-is-now-officially.html>`_

0 commit comments

Comments
 (0)