Hi,t-set can be used to define a new variable and set its value:
Syntax is,
<t t-set=”variable_name” t-value=”value of the variable” />
Example:
<t t-set=”count” t-value=”0” />
This will create a new variable ‘count’ and set its value as zero. We can set the value of this variable using a function.
<t t-set=”count” t-value=”my_function()” />
Here, the value of ‘count’ will be the value returned from the function ‘my_function’. When we define a variable, we don’t need to specify a specific type of this variable. We can have several types of values such as numbers, strings, arrays (lists) and dictionaries, etc. If we need to define a dictionary, we can do it like this,
<t t-set=”my_dict” t-value=”{'my': 'first', 'my2': 'second' }” />
Just like this, we can use lists also. Iterating over the different values of a list or dictionary can be achieved by using a loop.
Hope it helps