Template Attribute Language

The Template Attribute Language (TAL, loosely translated as: " attribute -based template language ") is a template language for generating HTML and XML (and thus XHTML ) pages. It aims to facilitate the collaboration of designers and programmers by both the templates and the results pages are valid documents of their markup language. The templates can therefore be edited with design tools who know nothing of TAL, but leave them unmolested unknown attributes.

The TAL was developed within the web application server Zope; there is usually spoken of Zope Page Templates.

TAL completely abstracted from the language used; only the language used for expression evaluation (usually TALES ) may depend on the implementation language-specific expressions allow, mostly in Python.

  • Python 4.1
  • 4.2 Java
  • 4.3 Javascript
  • 4.4 Perl
  • PHP 4.5
  • 4.6 XSL

Overview

TAL templates are created as a result of documents where the variable contents can be overridden by specific attributes; Program code outside elements, such as PHP or JSP is not necessary. In the following example, the element would

    For the designer visible heading < / h1 > from a standard HTML editor as

    For the designer visible heading < / h1 > treated during the use of the templates by the application server,

    A completely different heading < / h1 > results. Specifying a constant string is of course a rather negligible in practice case; the possible attribute values ​​are defined by the TAL Expression Syntax ( TALES ). For example, Python expressions can be used in the existing Python implementations.

When XML documents are to be generated, it is important to write the XML namespace ( xmlns: tal = " http://xml.zope.org/namespaces/tal ").

Macros

With the help of METAL ( Macro Expansion TAL) it is possible to reuse code across template boundaries.

Internationalization

Using the i18n attributes (see i18n TAL), localized pages are generated.

Attributes

The following attributes are recognized, where the prefix normally " tal: " must be preceded by:

If an element has multiple TAL attributes are evaluated (regardless of the order of their listing ) in the above (logically obvious ) this order; the order of the variable definitions within a "define" attribute, however, is significant, so that a variable can be used in later assignments in the same define- attribute.

If there is no element that offers itself as the bearer of the TAL attributes, special VALLEY tags can be used; In this case, the prefix " tal: " is optional. example:

    ... The code within the element is used here, for example if the context ( whatever that means for the application server you are using, for example, an object) defined variable " itemlist " is true, in the case of a list that is at least contains an element. The identifier following the colon is arbitrary; he must be the same only with opening and closing tags.

Use

TAL / TALES / METAL be used by the following projects:

  • Web application server Zope
  • Roundup ( issue tracker )

Other implementations

Besides the original Zope implementation, there is ( not exhaustive ) the following:

Python

  • Simpletal ( http://www.owlfish.com/software/simpleTAL/, TAL - guide)
  • OpenTAL ( http://savannah.nongnu.org/projects/opental/ )
  • ZPT ( http://zpt.sourceforge.net/ ), a standalone version of Zope Page Templates

Java

  • JPT: Java Page Templates ( http://christophermrossi.com/jpt/ )
  • JavaZPT ( http://javazpt.sourceforge.net/ )

Javascript

  • Distal ( http://code.google.com/p/distal )

Perl

  • PETAL, the Perl Template Attribute Language ( http://search.cpan.org/dist/Petal/ )
  • Template - TAL ( http://search.cpan.org/dist/Template-TAL/ )

PHP

  • PHPTAL, the PHP incarnation of TAL ( http://phptal.org/ )

XSL

764934
de