Twig template variables: Variable types
Each Twig template variable shows a type of value (for example, a text, a date or a list). The type of value tells you how to use the variable in a template.
Twig code in a template
- Between
{{and}}, enter a variable to show a value in the document (for example,{{ contact.FirstName }}) - Between
{%and%}, enter a Twig tag that controls the document (for example, anifstatement or aforloop)
The name of a variable has two or more parts, with a dot between each part. The first part is the record (for example, contact). The next part is the data of the record (for example, FirstName).
Variable types
| Type of value | How to use the variable | Example |
|---|---|---|
Text or number | Enter the variable between |
|
Price or total | Use the |
|
Date | Use the |
|
Condition (true or not true) | Put the variable in a Twig |
|
Record | Add one more variable after the variable. After the dot, you can use all variables of that type of record. |
|
List of records or values | Put the variable in a Twig |
|
Formatted content | Use the |
|
Find the type of a variable
- "True if" at the start of the description: the variable shows if a condition is true
- "Shows a list": the variable shows a list of records or values
- "Shows the … record", with a tip to add one more variable: the variable shows a record
- A note about the
moneyformat,dateformatorrawTwig filter: the variable shows a price, a date or formatted content
Each page of Twig template variables also has help sections for the types of value in that page (for example, "Variables that check a condition").