Types
eZ template supports different kinds of variable types. Some types can be input directly
in the template while others require operators* to create them, this also means that it's possible to
create custom types. Directly input types are numeric values, strings and variables, while operator
created types are boolean and arrays. For custom types objects are used, meaning that it's up to operators
to create proper objects and up the objects to know how to represent themselves.
Numerical values
Numerical values are either integers or floats, they are input as normal numbers.
{42}
{1.5}
{1000.98}
{-200}
Strings
Strings are input by enclosing the text in either ' or "** quotes, if you don't do this, they will either
be interpreted as identifiers or function names. If you need to use a quote inside the string you can
either switch to the other enclosing quote type or backslash the character with a \.
The } character must also be backslashed.
Strings do not support variable expansion as they do in PHP, to create strings with text and variables
you must use the concat operator.
{'this is some text'}
{"again some more text"}
{'quoted "text"'}
{"single 'quoted'"}
{'mixing \'quote\' "types" {still inside string\}'}
Booleans
Booleans are either true or false, and must be input using either the true() or false()
operators.
It's possible to use integers as booleans for some operators and functions but they are not real booleans,
0 is false and any other value is true***. Booleans have several operators that can be used to modify
them, see logical operators.
{true()}
{false()}
Arrays
Arrays are containers that can contain any other type including arrays. Arrays may be simple vectors
where items are accessed with numbers, or they can be a hash map (also known as associative array) which
means lookup is done with strings.
Elements are fetched using attribute lookup, the attribute is either a number or an identifier (string).
Arrays must be created with the array operator or set from PHP code, associative arrays are created
with the hash operator.
{array(1,2,5)}
{array('this','is','a','test')}
{hash('red',1,'blue',2,'green',3)}
Objects
Objects are not a specific type but are created from classes by PHP code or by special operators. By using objects
it's possible to do more advanced template handling, for instance objects may contain state information
or other required bookkeeping. Objects may also sometimes inter-operate with associative arrays since they
support lookup using identifiers. Identifier lookup for objects is entirely up to the specific object,
it's only required that the class creates a couple of functions. See the objects page for information on
creating your own objects.
Variables
Variables are containers for other types. Variables allow for dynamic content and are often supplied by PHP code for
templates to display or handle. The variable consists of an identifier name and a namespace, the variable starts with
a $ and namespaces are delimited with :. See namespaces for more information on how they work.
{$number}
{$my_var}
{$Name:Space:number}
|