chameleon

Getting Started and API Reference

This section documents the package as a Python library. To learn about the page template language, consult the language reference. Getting started There are several template constructor classes available, one for each of the combinations text or xml, and string or file. The file-based constructor requires an absolute path. To set up a templates directory once, use the template loader class: Then, to …

Getting Started and API Reference Read More »

General and Development Configuration

Most settings can be provided as keyword-arguments to the template constructor classes. There are certain settings which are required at environment level. Acceptable values are “0”, “1”, or the literals “true” or “false” (case-insensitive). General usage The following settings are useful in general. CHAMELEON_EAGER Parse and compile templates on instantiation. CHAMELEON_CACHE When set to a file system path, the template compiler …

General and Development Configuration Read More »

Language Reference: Basics (TAL)

The template attribute language is used to create dynamic XML-like content. It allows elements of a document to be replaced, repeated, or omitted. Statements These are the available statements: Statement Description tal:define Define variables. tal:switch Defines a switch condition tal:condition Include element only if expression is true. tal:repeat Repeat an element. tal:case Includes element only if expression …

Language Reference: Basics (TAL) Read More »

Language Reference: Expressions (TALES)

The Template Attribute Language Expression Syntax (TALES) standard describes expressions that supply Basics (TAL) and Macros (METAL) with data. TALES is one possible expression syntax for these languages, but they are not bound to this definition. Similarly, TALES could be used in a context having nothing to do with TAL or METAL. TALES expressions are described below with any delimiter or quote markup …

Language Reference: Expressions (TALES) Read More »

Language Reference: Translation (I18N)

Translation of template contents and attributes is supported via the i18n namespace and message objects. Messages The translation machinery defines a message as any object which is not a string or a number and which does not provide an __html__ method. When any such object is inserted into the template, the translate function is invoked first to see if it needs …

Language Reference: Translation (I18N) Read More »

Language Reference: Code Style

${…} operator The ${…} notation is short-hand for text insertion. The Python-expression inside the braces is evaluated and the result included in the output (all inserted text is escaped by default): To escape this behavior, prefix the notation with a backslash character: \${…}. Note that if an object implements the __html__ method, the result of this method will be inserted …

Language Reference: Code Style Read More »

Integration with Popular Web Frameworks

Integration with Chameleon is available for a number of popular web frameworks. The framework will usually provide loading mechanisms and translation (internationalization) configuration. Pyramid pyramid_chameleon is a set of bindings that make templates written for the Chameleon templating system work under the Pyramid web framework. Zope 2 / Plone Install the five.pt package to replace the reference template …

Integration with Popular Web Frameworks Read More »