<mt:Var>
A function tag used to store and later output data in a template.
Attributes:
- name (or var)
Identifies the template variable. The 'name' attribute supports a variety of expressions. In order to not conflict with variable interpolation, the value of the name attribute should only contain uppercase letters, lowercase letters, numbers and underscores. The typical case is a simple variable name:
<mt:Var name="foo">
Template variables may be arrays, or hash variables, in which case you may want to reference a specific element instead of the array or hash itself.
This selects the second element from the 'foo' array template variable:
<mt:Var name="foo[1]">
This selects the 'bar' element from the 'foo' hash template variable:
<mt:Var name="foo{bar}">Sometimes you want to obtain the value of a function that is applied to a variable (see the 'function' attribute). This will obtain the number of elements in the 'foo' array:
<mt:Var name="count(foo)">
- op
Along with the 'value' attribute, this allows the application of a number of mathematical operators (see the If tag for which are supported).
- value
If provided with the 'op' attribute, provides the operand for the specified mathematical operation.
If provided without the 'op' attribute, this causes the variable to be assigned the value specified. In this way, this tag is useful for setting variables as well.
- function
For array template variables, this attribute supports:
- pop
Takes an element from the end of the array (last element).
- shift
Takes an element from the front of the array (index 0).
- count
Returns the number of elements in the array template variable.
For hash template variables, this attribute supports:
- delete
Only valid when used with the 'key' attribute, or if a key is present in the variable name.
- count
Returns the number of keys present in the hash template variable.
- pop
- index
Identifies an element of an array template variable.
- key
Identifies a key of a hash template variable.
- default
If the variable is undefined or empty, this value will be output instead.
- to_json
Formats the variable in JSON notation.
- glue
For array template variables, this attribute is used in joining the values of the array together.

Su
June 27, 2008 5:17 PM | Reply
The op attribute is defined in the wiki .