From fa446e1f12547c8baa943edb102c34d7747e5724 Mon Sep 17 00:00:00 2001 From: "Michael R. Bernstein" Date: Tue, 2 Dec 2014 09:50:02 -0600 Subject: [PATCH 1/5] 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 `_ From 93fc32f1ba4c7088691d8c84b22e1b76fa9b2bae Mon Sep 17 00:00:00 2001 From: "Michael R. Bernstein" Date: Tue, 2 Dec 2014 09:51:20 -0600 Subject: [PATCH 2/5] Typos --- docs/scenarios/web.rst | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/docs/scenarios/web.rst b/docs/scenarios/web.rst index 7fa1885..87ecd52 100644 --- a/docs/scenarios/web.rst +++ b/docs/scenarios/web.rst @@ -416,16 +416,13 @@ into the corresponding block in the :file:`base.html` page. 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. +`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: +Here is an example of a template tags in Chameleon: The *page templates* language is used within your document structure as special element attributes and text markup. Using a set of simple From 2aa73607ac45627f129fa2cdfb18af4f8cbe4f36 Mon Sep 17 00:00:00 2001 From: "Michael R. Bernstein" Date: Tue, 2 Dec 2014 09:52:55 -0600 Subject: [PATCH 3/5] Cleanup. --- docs/scenarios/web.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/scenarios/web.rst b/docs/scenarios/web.rst index 87ecd52..08cc6ab 100644 --- a/docs/scenarios/web.rst +++ b/docs/scenarios/web.rst @@ -418,12 +418,10 @@ Chameleon --------- `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 language used is page templates, originally a Zope invention, 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 Chameleon: - 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 From c04def9e05d52bee83b907bad1c7615f011b2a4a Mon Sep 17 00:00:00 2001 From: Michael Bernstein Date: Sun, 7 Dec 2014 11:43:01 -0600 Subject: [PATCH 4/5] Expanded and edited the Chameleon section. --- docs/scenarios/web.rst | 52 +++++++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/docs/scenarios/web.rst b/docs/scenarios/web.rst index 08cc6ab..b267f74 100644 --- a/docs/scenarios/web.rst +++ b/docs/scenarios/web.rst @@ -416,27 +416,49 @@ into the corresponding block in the :file:`base.html` page. Chameleon --------- -`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. +`Chameleon `_ Page Templates are an HTML/XML template +engine implementation of the `Template Attribute Language (TAL) `_, +`TAL Expression Syntax (TALES) `_, +and `Macro Expansion TAL (Metal) ` syntaxes. -The language used is page templates, originally a Zope invention, 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. +Chameleon is available for Python 2.5 and up (including 3.x and pypy), and +is commonly used by the `Pyramid Framework `_. -The template engine compiles templates into Python byte-code and is optimized for speed. For a complex template language, the performance is very good. +Page Templates add within your document structure special element attributes +and text markup. Using a set of simple language constructs, you control the +document flow, element repetition, text replacement and translation. Because +of the attribute-based syntax, unrendered page templates are valid HTML and can +be viewed in a browser and even edited in WYSIWYG editors. This can make +round-trip collaboration with designers and prototyping in a browser easier. -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: +The basic TAL language is simple enough to grasp from an example: .. code-block:: html -

Hello, ${'world'}!

+

Hello, World!

+ + + + +
+ +
+ + + + +The `` pattern for text insertion is common +enough that if you do not require strict validity in your unrendered templates, +you can replace it with a more terse and readable syntax that uses the pattern +`${expression}`, as follows: + +.. code-block:: html + + + +

Hello, ${world}!

@@ -447,6 +469,10 @@ is simple enough to grasp from an example: + +But keep in mind that the full `Default Text` +syntax allows for default content in the unrendered template. + .. rubric:: References .. [1] `The mod_python project is now officially dead `_ From 53bf93d76770ba00ea6dcafbf4f1eb18b38dd905 Mon Sep 17 00:00:00 2001 From: Michael Bernstein Date: Sun, 7 Dec 2014 13:43:48 -0600 Subject: [PATCH 5/5] A bit more editing and cleanup of the Chameleon section. --- docs/scenarios/web.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/scenarios/web.rst b/docs/scenarios/web.rst index b267f74..c879438 100644 --- a/docs/scenarios/web.rst +++ b/docs/scenarios/web.rst @@ -422,14 +422,15 @@ engine implementation of the `Template Attribute Language (TAL) ` syntaxes. Chameleon is available for Python 2.5 and up (including 3.x and pypy), and -is commonly used by the `Pyramid Framework `_. +is commonly used by the `Pyramid Framework `_. Page Templates add within your document structure special element attributes and text markup. Using a set of simple language constructs, you control the document flow, element repetition, text replacement and translation. Because of the attribute-based syntax, unrendered page templates are valid HTML and can be viewed in a browser and even edited in WYSIWYG editors. This can make -round-trip collaboration with designers and prototyping in a browser easier. +round-trip collaboration with designers and prototyping with static files in a +browser easier. The basic TAL language is simple enough to grasp from an example: @@ -471,7 +472,7 @@ you can replace it with a more terse and readable syntax that uses the pattern But keep in mind that the full `Default Text` -syntax allows for default content in the unrendered template. +syntax also allows for default content in the unrendered template. .. rubric:: References