For the complete documentation index, see llms.txt. This page is also available as Markdown.

$var

Creates a custom variable in your template which you can access from other parts of your template

Note:

Variables must be added to templates before (higher up in the template) they are used.

Examples

Good: {{$var "tax_rate" 0.07}} //Variable is declared before it is used

Tax Rate: {{$number tax_rate "0%"}}

Bad:

Tax Rate: {{$number tax_rate "0%"}}

{{$var "tax_rate" 0.07}} //Variable is declared after it is used

Signature

{{$var name value}}

Arguments

Name
Description
Type
Required

name

The name of the variable. This will be used to access it later. Must be a valid JavaScript key

String

value

The value of the variable

Any

Returns

This function does not have a return value.

Example #1 - Basic

Example #2 - Advanced

Create a custom variable and set the value to the results of the filter function where we filter items that have a quantity of 10 or more.

Repeat the section for each item in the custom variable

Variables can only be accessed after the point in the template where they are declared.

Last updated

Was this helpful?