Skip to main content

Basic Variable Syntax

Variables in TemplateMark are enclosed in double curly braces and reference properties from your data model.
{{variableName}}

Simple Variables

Access top-level properties directly by name:
Hello {{name}}!
Example with data:
{
  "$class": "[email protected]",
  "name": "John Doe"
}

Nested Object Properties

Access nested properties using dot notation:
{{#clause address}}
{{line1}},
{{city}}, {{state}},
{{country}}
{{/clause}}
Example with nested data:
{
  "$class": "[email protected]",
  "address": {
    "line1": "1 Main Street",
    "city": "Boston",
    "state": "MA",
    "country": "USA"
  }
}

Date Formatting

Format date and time values using the as keyword with format strings:
{{dateVariable as "FORMAT_STRING"}}

Common Date Formats

{{effectiveDate as "DD MMMM YYYY"}}
Output: 01 February 2025
Example in context:
{
  "$class": "[email protected]",
  "effectiveDate": "2025-02-01T00:00:00Z",
  "disclosingParty": "Tech Innovators Inc."
}

Number Formatting

Format numeric values using the as keyword with numeral.js format patterns:
{{numberVariable as "FORMAT_PATTERN"}}

Common Number Formats

{{amount as "0,0.00"}}
Output: 1,250.00
Example in context:
{
  "$class": "[email protected]",
  "amount": 250.00,
  "currency": "USD",
  "vatPercent": 10
}

Special Variables

The now Variable

TemplateMark provides an implicit now variable representing the current date and time:
Today is {{% return now.toISOString() %}}.
The now variable is only accessible within formula expressions (between {{% %}}).

The this Variable

Within list iterations and clause blocks, use this to reference the current item:
{{#ulist items}}
- {{this}}
{{/ulist}}
See the Lists documentation for more details.

Best Practices

Choose variable names that clearly indicate their purpose:
Good: {{customerName}}, {{invoiceDate}}
Avoid: {{x}}, {{data1}}
Raw date values are not human-readable. Always use the as formatter:
Good: {{eventDate as "D MMMM YYYY"}}
Avoid: {{eventDate}}
Use consistent number formatting for currency values:
{{amount as "0,0.00"}} {{currency}}

Conditionals

Learn about conditional rendering based on variable values

Formulas

Perform calculations and transformations on variables

Lists

Iterate over array variables

Build docs developers (and LLMs) love