Data types

Properties in Sufio templates are of one of the basic data types below, such as boolean, number, or string.

Most properties are also implemented as node objects, which means they can output their formatted values as well as additional information about the property.

Basic data types

Each property is of one of the following data types.

address

A complete address in a country-specific format according to the language of your document.

Code
{{ account.address }}
Output
42 Geary Street
San Francisco, CA 94108
United States

Depending on the country-specific format, the address may contain the following fields:

  • address.city
  • address.country
  • address.country_code
  • address.postal_code
  • address.region
  • address.region_code
  • address.street

Use the field as an attribute to return only that field:

Code
{{ account.address.city }}
Output
San Francisco

amount

A numerical value representing a financial amount. You can format the value as a price, perform numerical operations, or apply one of the math filters, for example, sum.

Code
{{ order.total_price }}
Output
44.61

array

A list of variables of any type.

Code
{{ order.customer.tags }}
Output
['Active subscriber', 'Monthly payment', 'Premium plan']

boolean

A binary value, either True or False.

Code
{{ document.is_invoice }}
Output
True

date

A date or a datetime, in ISO 8601 format.

Code
{{ document.dates.issue_date }}
Output
2024-08-04 00:00:00

Use the format_date filter to return the date in the format based on the document language.

Code
{{ document.dates.issue_date | format_date }}
Output
Aug. 4, 2024

image

The file path to an image displayed on the documents, such as logo.

Code
{{ account.logo }}
Output
/media/cache/s/sufio-test/c13s_1p6y1n_document.png

number

Numeric values, including floats and integers. You can perform numerical operations or apply one of the math filters to number properties.

Code
{{ document.lines[0].quantity }}
Output
3

string

Any series of characters.

Code
{{ document.thanks }}
Output
Thank you for choosing ACME.

Node object

Most properties in Sufio templates are implemented as node objects.

node objects can return both the underlying values of properties (e.g., 12.3) and their formatted versions (e.g., €12.30). These objects also include additional information about each property, such as its type, ID, or name.

Instead of formatting each property manually in the document template, node objects allow you to do this automatically. For example, you can use a simple iterator to display correctly formatted properties of different types—such as item names, quantities, and unit prices.

node

The underlying value of the property, returned without formatting.

Code
{{ document.totals.amonut_due }}
Output
45.52
Code
{{ document.totals.issue_date }}
Output
2024-07-25 00:00:00

node.css_classes

CSS classes that should be applied to the HTML element that renders the property in the template.

These might include various classes related to the data_type and name of the property and its status.

Code
<div class="{{ document.totals.amonut_due.css_classes }}">{{ document.totals.amonut_due.text }}</div>
Output
<div class="amount total_amount_due visible">£45.52</div>
Code
<div class="{{ document.dates.issue_date.css_classes }}">{{ document.dates.issue_date.text }}</div>
Output
<div class="date issue_date visible">July 25, 2024</div>

node.data_type

The data type of the property. Possible types:

Code
{{ document.totals.amonut_due.data_type }}
Output
amount
Code
{{ document.dates.due_date.data_type }}
Output
date

node.id

The unique identifier of the property.

Code
{{ document.totals.amonut_due.id }}
Output
document-totals-amount-due
Code
{{ document.dates.issue_date.id }}
Output
document-dates-issue-date

node.is_visible

A boolean value which indicates if the property should be visible on the document. This depends on the document type, your settings on the Design page, and whether the property has a value.

 If True, the item should be visible.

Code
{{ document.totals.amonut_due.is_visible }}
Output
True
Code
{{ document.dates.due_date.is_visible }}
Output
True

Note

You can always access property values or use them in conditional statements in the template, regardless of whether the properties are visible or not.

node.node_name

The name of the property.

Code
{{ document.totals.amonut_due.node_name }}
Output
amonut_due
Code
{{ document.totals.issue_date.node_name }}
Output
issue_date

node.text

The formatted value of the property, which can be also be translated to the document language or formatted in the language-specific format.

Code
{{ document.totals.amonut_due.text }}
Output
£45.52
Code
{{ document.dates.due_date.text }}
Output
July 25, 2024

node.title

The title of the property, which is used as a label displayed on the document.

The output value is translated to the document language.

Code
{{ document.totals.amonut_due.title }}
Output
Amount due
Code
{{ document.dates.due_date.title }}
Output
Due date