| 3253 | | <mt:Var name="count(foo)"> |
|---|
| | 3253 | <$mt:Var name="count(foo)"$> |
|---|
| | 3254 | |
|---|
| | 3255 | Excluding the punctuation required in the examples above, the 'name' |
|---|
| | 3256 | attribute value should contain only alphanumeric characters and, |
|---|
| | 3257 | optionally, underscores. |
|---|
| | 3258 | |
|---|
| | 3259 | =item * value |
|---|
| | 3260 | |
|---|
| | 3261 | In the simplest case, this attribute triggers I<assignment> of the |
|---|
| | 3262 | specified value to the variable. |
|---|
| | 3263 | |
|---|
| | 3264 | <$mt:Var name="little_pig_count" value="3"$> # Stores 3 |
|---|
| | 3265 | |
|---|
| | 3266 | However, if provided with the 'op' attribute (see below), the value becomes |
|---|
| | 3267 | the operand for the specified mathematical operation and no assignment takes |
|---|
| | 3268 | place. |
|---|
| | 3269 | |
|---|
| | 3270 | The 'value' attribute can contain anything other than a double quote. If you |
|---|
| | 3271 | need to use a double quote or the value is very long, you may want to use |
|---|
| | 3272 | the L<SetVarBlock> tag or the L<setvar> global modifier instead. |
|---|
| 3257 | | Along with the 'value' attribute, this allows the application of |
|---|
| 3258 | | a number of mathematical operators (see the L<If> tag for which |
|---|
| 3259 | | are supported). |
|---|
| 3260 | | |
|---|
| 3261 | | =item * value |
|---|
| 3262 | | |
|---|
| 3263 | | If provided with the 'op' attribute, provides the operand for the |
|---|
| 3264 | | specified mathematical operation. |
|---|
| 3265 | | |
|---|
| 3266 | | If provided without the 'op' attribute, this causes the variable |
|---|
| 3267 | | to be I<assigned> the value specified. In this way, this tag |
|---|
| 3268 | | is useful for setting variables as well. |
|---|
| | 3276 | Used along with the 'value' attribute to perform a number of mathematical |
|---|
| | 3277 | operations on the value of the variable. When used in this way, the stored |
|---|
| | 3278 | value of the variable doesn't change but instead gets transformed in the |
|---|
| | 3279 | process of being output. |
|---|
| | 3280 | |
|---|
| | 3281 | <$mt:Var name="little_pig_count"> # Displays 3 |
|---|
| | 3282 | <$mt:Var name="little_pig_count" value="1" op="sub"$> # Displays 2 |
|---|
| | 3283 | <$mt:Var name="little_pig_count" value="2" op="sub"$> # Displays 1 |
|---|
| | 3284 | <$mt:Var name="little_pig_count" value="3" op="sub"$> # Displays 0 |
|---|
| | 3285 | |
|---|
| | 3286 | See the L<If> tag for the list of supported operators. |
|---|
| | 3287 | |
|---|
| | 3288 | =item * prepend |
|---|
| | 3289 | |
|---|
| | 3290 | When used in conjuction with the 'value' attribute to store a value, this |
|---|
| | 3291 | attribute acts as a flag (i.e. 'prepend="1"') to indicate that the new value |
|---|
| | 3292 | should be added to the front of any existing value instead of replacing it. |
|---|
| | 3293 | |
|---|
| | 3294 | <$mt:Var name="greeting" value="World"$> |
|---|
| | 3295 | <$mt:Var name="greeting" value="Hello " prepend="1"$> |
|---|
| | 3296 | <$mt:Var name="greeting"$> # Displays: Hello World |
|---|
| | 3297 | |
|---|
| | 3298 | =item * append |
|---|
| | 3299 | |
|---|
| | 3300 | When used in conjuction with the 'value' attribute to store a value, this |
|---|
| | 3301 | attribute acts as a flag (i.e. 'append="1"') to indicate that the new value |
|---|
| | 3302 | should be added to the back of any existing value instead of replacing it. |
|---|
| | 3303 | |
|---|
| | 3304 | <$mt:Var name="greeting" value="Hello"$> |
|---|
| | 3305 | <$mt:Var name="greeting" value=" World" append="1"$> |
|---|
| | 3306 | <$mt:Var name="greeting"$> # Displays: Hello World |
|---|