Template Expressions
What are Template Expressions?
Template Expressions are used to insert dynamic data into your export files. It even allows you to perform actions to your data using predefined functions.
Expressions only recognize text between {{
… }}
or {%
… %}
as expression code. Anything not surrounded by those tags is treated as-is.
GL Processor Cloud uses a derivative of the Liquid template language. You can read a more in-depth introduction to the Liquid template language here.
GL Processor Cloud also uses the Scriban library to implement the Liquid template language. You can read a more in-depth documentation to the Scriban library here.
Objects and Fields
Liquid evaluates and replaces any text inside {{
and }}
.
For example, if you want to insert the value from the Amount field, you could write the following expression:
Template | Output |
---|---|
|
|
Filters and Functions
Functions or methods in other languages are referred to as filters in liquid. Filters can be used for a variety of things, such as converting a string to uppercase, formatting a date, performing math computations, and lots more.
Filters are called by adding a pipe character |
between the field and the filter. For example,
Input | Template | Output |
---|---|---|
|
|
|
|
|
|
|
|
|
Whitespaces
When writing expressions, whitespace is generally preserved outside of the curly braces. by contrast, any whitespace contained between {{
and }}
is generally ignored.
In the following table, the · symbol will represent an invisible space character.
Template | Output |
---|---|
|
|
|
|
|
|
msg = |
|
These examples show that anything outside of {{...}}
is preserved, which can potentially add unwanted whitespace to your data.
To have more control of whitespaces in your expressions, the use of {{- … -}}
or {%- … -%}
tags can be used. This will suppress all whitespace within the brackets.
Template | Output |
---|---|
|
|
Conditional Operators
Conditional operators evaluate and replaces any text inside {% and %}.
For example, if you wanted to evaluate a property value and use different outputs based on the evaluation you could write:
Input | Template | Output |
---|---|---|
Credit |
| C |
Comments
Comments may be added to the expressions to provide a description or notes.
For example, if you wanted to add comments to an expression you could write:
Template | Output |
---|---|
| 99.99 |