Template Attribute Language Expression Syntax

The Template Attribute Language Expression Syntax ( TALES ) describes the syntax for the evaluation of the Template Attribute Language (TAL ) and Macro Expansion Template Attribute Language (METAL) used for attribute values ​​expressions. The possibility for this to use a different syntax than TALES is expressly provided; usually TALES is not replaced, but extends it.

The web application server Zope TALES extends the specification in the context of Zope Page Templates.

  • 2.1 Simple Path Expression to access a macro
  • 2.2 loop path, python and string expressions
  • 2.3 Logical negation and TAL elements

Overview

TALES provides several methods available to formulate expressions that can be used in TAL and METAL attributes and are distinguished by an (optional ) prefix:

Types of expressions

Built- name

These names are usually supplemented by another, see Zope Page Templates.

Examples

Simple Path Expression to access a macro

Here is for example the location directory that contains a template file page, in turn, the macro was defined myform. In Zope Page Templates for instance, would here be here instead of location ( as the starting point of acquisition to Search page ) or container.

Loop path, python and string expressions

99 < / td >    line 99 < / td > issue:

1    line one < / td >
2    line two < / td > ' Notes:

  • The tal: repeat attribute creates a variable item and, with the help of the Python expression, a sequence of Dictionary, which is used to generate multiple HTML table rows
  • The special loop variables (eg number) for item will repeat on the services requested by TALES standard variable provided
  • Path expressions can also be used within string expressions

Logical negation and TAL elements

  ...   ... is_view_ok could be a method that is called from the context and checks the user read permission here. In "Else - branch " ( the syntax is nothing more than the "If- branch ", if and else are here freely chosen name, which even had been allowed to be the same ) is the logical condition of the if- branch vice versa, so that only one of the two runs.

760694
de