Zope Page Template engine based on Chameleon
Project description
Overview
This package provides a fast Zope Page Template implementation based on the Chameleon template compiler. It’s largely compatible with zope.pagetemplate.
Usage
Load the package component configuration file (configure.zcml).
Performance
Casual benchmarks pegs it 16x more performant than the reference implementations for Zope TAL and Genshi (using Python-expressions).
Compiler notes
The compiler is largely compatible with the reference implementation. The TAL implementation is based on the 1.4 language specification.
Some notable changes:
Tuple unpacking is allowed when defining variables:
tal:define="(a, b, c) [1, 2, 3]"
Generators are allowed in tal:repeat statements. Note that the repeat variable is not available in this case:
tal:repeat="i <some generator>"
Attribute-access to dictionary entries is allowed in Python-expressions, e.g.
dictionary.key
can be used instead of dictionary['key'].
The default expression type is Python.
Genshi expression interpolation syntax is supported outside tags and inside static attributes, e.g.:
<span class="hello-${'world'}"> Hello, ${'world'}! </span>
Development
If you want to use the code directly from trunk (recommended only for development and testing usage), provide chameleon.zpt==dev as your dependency.
The code is maintained in a subversion repository:
svn://svn.repoze.org/svn/chameleon.zpt
Want to contribute? Join #zope3-dev on Freenode IRC.
Changelog
1.1 (released 23/09/2009)
Add support for text templates. [wichert]
1.0.0 (released 06/07/2009)
Insert an empty string in place for None with tal:content (LP #379769).
Include changelog in long description. [hannosch]
1.0b17 (released 20/05/2009)
Fixed whitespace issue. [malthe]
Update to latest Chameleon. [malthe]
1.0b16 (released 22/04/2009)
Raise syntax error during validation if metal:use-macro is used together with metal:define-macro. [malthe]
Add support for metal:extend-macro. [sidnei, malthe]
1.0b15 (released 17/04/2009)
Pass all keyword arguments to template superclass constructor. [malthe]
Define macros as a transient symbol; this fixes an issue where the render_macro method would not honor a macros parameter that was passed in. [malthe]
1.0b14 (released 08/04/2009)
Set template and macros symbols only if not explicitly passed to the template. [malthe]
Reverted to have template being the currently-being-executed template, and have a macros which refers to the macros from the source template instance. To refer to macros in the current template macros.<<name>> should be used. [sidnei]
1.0b13 (released 01/04/2009)
Added built-in name template, which refers to the template instance. This symbol is introduced to make it possible to refer to macros within the current template (e.g. template.macros.<name>). [malthe]
1.0b12 (released 31/03/2009)
Updated language adapter to work with ‘structure’ meta attribute.
Providing dynamic attributes on a TAL-element should fail. See LP #340078. [malthe]
1.0b11 (released 05/03/2009)
Fixed bug where whitespace would prevent matching. [malthe]
Added parser option to disable interpolation escaping. [malthe]
Enable DEBUG_MODE while running the tests. Some tests expect it to be enabled. [sidnei]
1.0b10 (released 22/02/2009)
Expressions inside variable substitutions are now escaped by default, unless the result is an object that has a __html__ method. [malthe]
When filling a macro slot, replace the entire element, rather than filling its contents. [malthe]
1.0b9 (released 29/01/2009)
Do not depend on component configuration; instead, fall back to a default “registry”, modelled as a simple Python dictionary. [malthe]
Depend on utility and adapter directives from repoze.zcml rather than using “stock” utility and adapter directives from zope.component. This prevents chameleon.zpt from requiring zope.security (and thus zope.location, zope.publisher, and zope.traversing). [chrism]
1.0b8 (released 12/18/2008)
Added support for recursive expression translators. [malthe]
1.0b7 (released 12/17/2008)
Right-strip escape character from string-expressions (the semicolon ‘;’ character). [malthe]
1.0b6 (released 12/03/2008)
Added a interpolation meta attribute to control $-interpolation of expressions. This defaults to true for chameleon.zpt. [seletz]
1.0b5 (released 11/29/2008)
Removed unused imports, thanks to PyFlakes. [hannosch]
Updated handling of static attributes. [malthe]
1.0b4 (released 11/19/2008)
Allow empty expressions; for string-expressions, this means an empty string, rather than no expression. [malthe]
Fixed string escape issue. [malthe]
Fixed issue where translation pragma would be reset if a non-matching pragma was found. [malthe]
Fixed bug that would parse global defines incorrectly. [malthe]
TAL- and METAL-elements now subclass the XHTML-element class; this allows mixed usage of TAL and METAL. [malthe]
validate-method is no longer formally required; errors are expected to be raised by the translate-method. [malthe]
Formalized character escape requirement; this allows compatibility with ZPT with regards to semi-colon escapes in attribute declarations. [malthe]
Allow chained pragmas. [malthe]
1.0b3 (released 11/12/2008)
Added default element to parser class. [malthe]
1.0b2 (released 10/28/2008)
Fixed missing attribute. [malthe]
1.0b1 (released 10/14/2008)
Tags are now omitted if a “tal:content” expression evaluates to None. This behavior differs from the reference implementation, but does away with the need for a similar “tal:condition” attribute. [malthe]
1.0a2 (released 10/2/2008)
Add a specialized TemplateLoader. [wichert]
Fixed an incompatibility where non-boolean values would be returned as a skip node value. [malthe]
1.0a1 (released 9/24/2008)
First release.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.