Glasnost Help and Documentation
Developers
Templates
TAL and METAL
TAL
TAL Statements: define
TAL Statements: define
tal:define="variable expression"
tal:define="global variable expression"
Variables can be defined with the define statement. Variables may be:
- local (default) or
- global, with the global keyword [1].
Examples
<div tal:define="title currentObject.label"> <h1 tal:content="title">Title</h1> </div>
<div tal:define="global title currentObject.label" tal:omit-tag=""></div> <h1 tal:content="title">Title</h1>
[1] Global variables can be used in any element processed after the element where they are defined. Redefining a global variable replaces its definition for the rest of the template.