The assign function can be used to store a value in a variable.

assign

{{assign var="" value=""}}

Arguments

The following arguments can be used with an assign:

ArgumentDescription
var

The name of the variable, which can be displayed in the content based on this name:
{{$<fieldname>}}

valueThe value to needs be stored in the variable.
scopeThe scope of the variable: 'parent', 'root', or 'global'.

Examples

Here's an example of the different ways a variable can be created:

assign

{{assign var="name1" value="Bobby"}}
{{assign "name2" "Ernst"}}
{{$name3 = "and others"}}

{{$name1}} - {{$name2}} - {{$name3}}

Output:
Bobby - Ernst - and others

Combining variables and/or text:

Combine variables and text

{{$variabele1 = "Deploy"}}
{{$variabele2 = "Teq"}}

{{assign var="combined" value= "`$variabele1``$variabele2`"}}

or

{{$combined = "`$variabele1` <-> `$variabele2`"}}

Output:
DeployTeq

Deploy <-> Teq

In addition, Smarty supports creating arrays:

Create an array

{{assign var='array' value=["Banana", "Apple", "Pear"]}}

{{$array = ["Banana", "Apple", "Pear"]}}


Output:
Array
(
    [0] => Banana
    [1] => Apple
    [2] => Pear
)