Template Attribute Language


The Template Attribute Language is a templating language used to generate dynamic HTML and XML pages. Its main goal is to simplify the collaboration between programmers and designers. This is achieved by embedding TAL statements inside valid HTML tags which can then be worked on using common design tools.
TAL was created for Zope but is used in other Python-based projects as well.

Attributes

The following attributes are used, normally prefixed by "tal:":
; define
; condition
; repeat
; content
; replace
; attributes
; omit-tag
; on-error
If a tag has more than one TAL attributes, they are evaluated in the above order.
In cases when no tag is present which lends itself to take the attributes, special TAL tags can be used, making the "tal:" prefix optional. e.g.:


...

would cause the code inside the tal:if tags to be used whenever the context contains variable "itemlist" with a true value, e.g. a list containing at least one element. The identifier following the colon is arbitrary; it simply needs to be there, and to be the same for the opening and closing tag.

METAL

The Macro Expansion Template Attribute Language complements TAL, providing macros which allow the reuse of code across template files. Both were created for Zope but are used in other Python projects as well.
METAL complements TAL with the ability to reuse code. It allows the developer to define and use macros, which in turn may have slots; when using a macro, variational content can be specified for a slot.
When generating XML documents, the XML namespace must be specified
.

METAL Attributes

The following attributes are recognised, normally requiring a „metal:“ prefix:
; define-macro
; define-slot
; use-macro
; fill-slot
; extend-macro
Normally, just one of those is used at a time.
In cases when no tag is present which lends itself to take the attributes, and in special cases when more than one METAL attribute is needed, special METAL tags can be used, making the „metal:“ prefix optional. E. g. :


...

...


tal:attributes="action context/designator">
...


Usage

TAL/TALES/METAL are used by the following projects:
Besides the original Zope implementation, there are :

Python