Skip to main content

An implementation of the TAL template language.

Project description

Overview

The z3c.pt package provides an alternative implementation of the TAL template language including i18n. It also provides a simple text template class that allows expression interpolation.

Casual benchmarks pegs it 11x more performant than zope.pagetemplate.

In a nutshell:

  • Templates are bytecode-compiled

  • Pluggable expression implementation

  • Support for expression interpolation using the ${<expression>}-format

  • Non-XML friendly

Note: The METAL macro language is not supported.

Usage

See README.txt inside package for general usage; to register the default expression types, load the package component configuration file (configure.zcml).

Template and expression language

The template and expression language is based loosely on the TAL 1.4 specification*. Some notable changes:

  1. Tuples are allowed in the tal:define statement:

    tal:define=”(a, b, c) [1, 2, 3]”

  2. Generators are allowed in tal:repeat statements. Note that the repeat variable is not available in this case.

    tal:repeat=”i <some generator>”

  3. Attribute-access to dictionary entries is allowed in Python-expressions, e.g.

    dictionary.key

    can be used instead of dictionary['key'].

  4. Expression interpolation is allowed in attributes and HTML content.

    <a href=”mailto:${context.email}”>${context.email}</a>

  5. Default expression type can be set using tal:default-expression. This is an alternative to providing the expression type before each expression.

Development

If you want to use the code directly from trunk (recommended only for development and testing usage), provide z3c.pt==dev as your dependency.

http://svn.zope.org/z3c.pt/trunk#egg=z3c.pt-dev

Changelog

Version 0.8 - March 19, 2008

  • Added support for ‘nocall’ and ‘not’ (for path-expressions).

  • Added support for path- and string-expressions.

  • Abstracted expression translation engine. Expression implementations are now pluggable. Expression name pragmas are supported throughout.

  • Formalized expression types

  • Added support for ‘structure’-keyword for replace and content.

  • Result of ‘replace’ and ‘content’ is now escaped by default.

  • Benchmark is now built as a custom testrunner

Version 0.7 - March 10, 2008

  • Added support for comments; expressions are allowed inside comments, i.e.

    <!– ${‘Hello World!’} –>

    Comments are always included.

Version 0.6 - February 24, 2008

  • Added support for text templates; these allow expression interpolation in non-XML documents like CSS stylesheets and javascript files.

Version 0.5 - February 23, 2008

  • Expression interpolation implemented.

Version 0.4 - February 22, 2008

  • Engine now uses cStringIO yielding a 2.5x performance improvement. Unicode is now handled correctly.

Version 0.3 - December 23, 2007

  • Code optimization; bug fixing spree

  • Added ViewPageTemplateFile class

  • Added support for i18n

  • Engine rewrite; improved code generation abstractions

Version 0.2 - December 5, 2007

  • Major optimizations to the generated code

Version 0.1 - December 3, 2007

  • First public 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.

Source Distribution

z3c.pt-0.8.1.tar.gz (27.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page