Template Attribute Language
   HOME

TheInfoList



OR:

The Template Attribute Language (TAL) is a templating language used to generate dynamic
HTML The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser. It can be assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaSc ...
and
XML Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable ...
pages. Its main goal is to simplify the collaboration between programmers and designers. This is achieved by embedding TAL statements inside valid HTML (or XML) tags which can then be worked on using common design tools. TAL was created for
Zope Zope is a family of free and open-source web application servers written in Python, and their associated online community. Zope stands for "Z Object Publishing Environment", and was the first system using the now common object publishing methodol ...
but is used in other
Python Python may refer to: Snakes * Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia ** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia * Python (mythology), a mythical serpent Computing * Python (pro ...
-based projects as well.


Attributes

The following attributes are used, normally prefixed by "tal:": ; define : creates local variables, valid in the element bearing the attribute (including contained elements) ; condition : decides whether or not to render the tag (and all contained text) ; repeat : creates a loop variable and repeats the tag iterating a sequence, e.g. for creating a selection list or a table ; content : replaces the content of the tag ; replace : replaces the tag (and therefore is not usable together with content or attributes) ; attributes : replaces the given attributes (e. g. by using tal:attributes="name name; id name" the name and id attributes of an input field could be set to the value of the
variable Variable may refer to: * Variable (computer science), a symbolic name associated with a value and whose associated value may be changed * Variable (mathematics), a symbol that represents a quantity in a mathematical expression, as used in many ...
"name") ; omit-tag : allows to omit the start and end tag and only render the content if the given expression is true. ; on-error : if an error occurs, this attribute works like the content tag. If a tag has more than one TAL attributes, they are evaluated in the above (fairly logical) 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 (whatever the application server defines the context to be, e.g. an object) 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 (METAL) complements TAL, providing macros which allow the reuse of code across template files. Both were created for
Zope Zope is a family of free and open-source web application servers written in Python, and their associated online community. Zope stands for "Z Object Publishing Environment", and was the first system using the now common object publishing methodol ...
but are used in other
Python Python may refer to: Snakes * Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia ** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia * Python (mythology), a mythical serpent Computing * Python (pro ...
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 Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable ...
documents, the XML namespace must be specified (xmlns:metal="http://xml.zope.org/namespaces/metal").


METAL attributes

The following attributes are recognised, normally requiring a „metal:“ prefix: ; define-macro : creates a macro ; define-slot : creates a slot inside a macro ; use-macro : uses a macro (normally given via a TALES path expression) ; fill-slot : when using a macro, replaces the default content of the given slot ; extend-macro : since
Zope Zope is a family of free and open-source web application servers written in Python, and their associated online community. Zope stands for "Z Object Publishing Environment", and was the first system using the now common object publishing methodol ...
v3: extends a macro, comparable to subclassing, by redefining of slots 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. (sketched with Roundup in mind): ... ...
...


Usage

TAL/TALES/METAL are used by the following projects: *
Zope Zope is a family of free and open-source web application servers written in Python, and their associated online community. Zope stands for "Z Object Publishing Environment", and was the first system using the now common object publishing methodol ...
(web application server) * Roundup (issue tracker)


Other implementations

Besides the original
Zope Zope is a family of free and open-source web application servers written in Python, and their associated online community. Zope stands for "Z Object Publishing Environment", and was the first system using the now common object publishing methodol ...
implementation, there are (not exhaustive):


Python

* SimpleTAL * OpenTAL * ZPT, a standalone version of Zope Page Templates * Chameleon, a fast reimplementation of Zope Page Templates


C#

* SharpTAL


Go (Golang)

* tal, a native Go implementation of TAL, TALES and METAL


JavaScript


template-tal
TAL Implementation for
NodeJs Node.js is an open-source server environment. Node.js is cross-platform and runs on Windows, Linux, Unix, and macOS. Node.js is a back-end JavaScript runtime environment. Node.js runs on the V8 JavaScript Engine and executes JavaScript code ou ...
* jstal * Distal * DomTal * ZPT-JS


Java

* JPT:
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mos ...
Page Templates * JavaZPT * ZPT-Java


Perl

* PETAL, the
Perl Perl is a family of two high-level, general-purpose, interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it also referred to its redesigned "sister language", Perl 6, before the latter's name was offic ...
Template Attribute Language * Template-TAL


Raku

* Flower, a Raku implementation of TAL, with some Petal and PHPTAL extensions.


PHP

* PHPTAL * Twital * Biscuit * zTAL


XSL

* XSLTal, transforming TAL via XSLT to XSLT


Common Lisp

* TALCL: A library that implements the TAL template language for common lisp


Similar implementations

* ATal – Not really a TAL implementation, but inspired on TAL concepts *
Thymeleaf Thymeleaf is a Java XML/XHTML/HTML5 template engine that can work both in web (servlet-based) and non-web environments. It is better suited for serving XHTML/HTML5 at the view layer of MVC-based web applications, but it can process any XML file e ...
- Not a TAL implementation, but a similar "natural template" language


References

{{Reflist


External links


Zope Page Templates Reference
(Zope Book) Zope Template engines