Template Syntax
Assignment



Normally, a template's data will come from its data model. However, sometimes it's convenient to assign a value to a variable in a template. You can do so using this syntax:

<assign variable = expression>

Dots aren't allowed in the name of the variable you assign to. The expression can be any valid expression. The equals sign is optional syntactic sugar.

Assignment is mainly useful for making your templates more readable. For example:

<assign foo = "This is the constant value of foo">
<assign bar = some.long.variable.name>

The assignment is performed at run-time. In the second example, if some.long.variable.name is undefined, bar will be set to null.

Previous: Switch-Case Next: Functions