Template Attribute Language

Template Attribute Language

The Template Attribute Language (TAL) is a templating language aimed to generate HTML and XML pages. Its main goal is to simplify the collaboration of programmers and designers by templates being proper HTML (or XML, respectively) which can be worked on using common design tools.

TAL was created for Zope but is used in other Python-based projects as well.

Overview

TAL Templates are often made from result pages with the variable content being replaced by special attributes; e.g., <h1 tal:content="string:Some altogether different headline"> The headline visible to the designer </h1>would be treated by a common HTML design tool as <h1> The headline visible to the designer </h1>while the application server, evaluating the tal:content attribute, would yield <h1> Some altogether different headline </h1>Of course, string literals are not the most common nor the most useful use case; the syntax of the possible attribute values is property of the TAL Expression Syntax (TALES) language. In the Python-based implementations, it is e.g. possible to use Python expressions.

Using METAL (Macro Expansion TAL) it is possible to re-use code from other templates.

When generating XML documents, it is important to specify the XML namespace xmlns:tal="http://xml.zope.org/namespaces/tal"

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 "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.: <tal:if condition="context/itemlist"> ... </tal:if>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.

Usage

TAL/TALES/METAL are used by the following projects:
* Zope (web application server)
* Roundup (issue tracker)
* Simplicity PHP framework

Other implementations

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

Python

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

JavaScript

* jstal (http://code.google.com/p/jstal/)

Java

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

Perl

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

PHP

* PHPtal (http://phptal.motion-twin.com)
* PHPtal (http://phptal.bukox.pl) - Polish site

XSL

* [http://wiki.flux-cms.org/display/FLX/Templates+XSLTAL XSLTal] , transforming TAL via XSLT to XSLT; http://svn.bitflux.ch/repos/public/popoon/trunk/components/transformers/xsltal/tal2xslt.xsl

External links

* [http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/AppendixC.stx Zope Page Templates Reference] (Zope Book)
* [http://wiki.zope.org/ZPT/TALSpecification14 TAL specification, v1.4]


Wikimedia Foundation. 2010.

Игры ⚽ Нужен реферат?

Look at other dictionaries:

  • Template Attribute Language — Die Template Attribute Language (TAL, sinngemäß übersetzt: „Attributbasierte Schablonensprache“) ist eine Templatesprache zur Generierung von HTML und XML (und damit auch XHTML ) Seiten. Sie verfolgt das Ziel, die Zusammenarbeit von Designern und …   Deutsch Wikipedia

  • Template Attribute Language Expression Syntax — Die Template Attribute Language Expression Syntax (TALES) beschreibt die Syntax für die Auswertung der von der Template Attribute Language (TAL) und Macro Expansion Template Attribute Language (METAL) für Attributwerte verwendeten Ausdrücke. Die… …   Deutsch Wikipedia

  • Template Attribute Language Expression Syntax — The Template Attribute Language Expression Syntax (TALES) is the recommended expression language used by TAL and METAL …   Wikipedia

  • Macro Expansion Template Attribute Language — Die Macro Expansion Template Attribute Language (METAL; engl., „Makrosprache für attributbasierte Schablonenverarbeitung“) erlaubt die Definition von Makros zur Wiederverwendung von Code in anderen Vorlagen. In der Regel wird sie im Zusammenhang… …   Deutsch Wikipedia

  • Template:Cite book —   [ …   Wikipedia

  • Template method pattern — [ LePUS3 ( [http://lepus.org.uk/ref/legend/legend.xml legend] ) ] In software engineering, the template method pattern is a design pattern.It is a so called behavioral pattern, and is unrelated to C++ templates.IntroductionIn a template pattern,… …   Wikipedia

  • Glossary of Unified Modeling Language terms — This glossary of Unified Modeling Language terms covers all versions of UML. Individual entries will point out any distinctions that exist between versions.A* Abstract An indicator applied to a classifier (e.g., actor, class, use case) or to some …   Wikipedia

  • ColdFusion Markup Language — CFML redirects here. For the radio station, see CFML FM. Cold Fusion Markup Language (CFML) Paradigm(s) imperative, object oriented Appeared in 1995 Designed by Jeremy Allaire Developer Adobe System …   Wikipedia

  • Web template hook styles — This article is a supplement to the Delimiting and embedding strategies. On web templates the separation of concerns (content from presentation) require a low level separation strategy to isolate template language from output language. Template… …   Wikipedia

  • Extensible Application Markup Language — Vorlage:Infobox Dateiformat/Wartung/MagischeZahl fehltVorlage:Infobox Dateiformat/Wartung/Standard fehlt Extensible Application Markup Language Dateiendung: .xaml MIME Type: application/xaml+xml …   Deutsch Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”