Skip to content

Content Expression Language

While writing your template, various advanced techniques can be used to manipulate your data directly in the editor. This allows you to combine and transform data without having to create new variables in your data source, or to add advanced conditions on your sentences, paragraphs or sections. To do this, we use our own Content Expression Language (CEL), which allows you to do various operations using your variables.

Where it's used

Expressions are used in two places; when adding conditions to your sentences, and when defining custom variables. When adding a condition, clicking advanced will allow you to write your own expression. When adding a custom variable, the expression is written in CEL.

Features

CEL Expressions can evaluate to the same data types are your variables can be, such as boolean or number.

Type Example Result Explanation
Text 'This is free text' This is free text Raw text
Boolean 1+2=3 True 1 plus two is equal to 3
Number 1+2 3 1 plus 2 equals 3
List ['a']+['b'] ['a', 'b'] The union of ['a'] and ['b']
Date 2021-05-26 12:13:14 2021-05-26 12:13:14 A DateTime

Note that you are of course able to use your variables in the expression, using the format {variableName}. You can apply formats to your variables as well in expressions, such as {myListVariable:count}.

When using expressions to define conditions, it is assumed that your expression results in a boolean (true/false) value. For custom variables, the result should match the type of the variable being defined.

List Operators

In the following examples, assume {x} is a list, {y} is a list, and {z} is some text.

Operator Result Type Example Explanation
Contains (List) Boolean {x} contains {y} Whether all elements in {y} are contained in {x}
Contains (Element) Boolean {x} contains {z} Whether {z} is in the list {x}
ContainsAny Boolean {x} containsany {y} Whether any of the elements in {x} are in {y}
= Boolean {x}={y} Whether {x} and {y} contain the same elements (in any order)
!= Boolean {x}!={y} Whether {x} and {y} do not contain the exact same elements (in any order)
- (List) List {x}-{y} Remove all elements in {y} from {x}
- (Element) List {x}-{z} Remove {z} from {x}
+ (List) List {x}+{y} Add all elements of y to x as a union
+ (Element) List {x}+{z} Add {z} to {x} if not exists
Intersect List {x} intersect {y} All elements in {x} also in {y}
Filter List {x} filter {{v}} contains 'a' Filters the list to elements that contain 'a'. {{v}} is a local variable referring to an element of {x}, denoted by the double brackets. The expression that filters the list can be any valid expression

Date Operators

In the following examples, assume {x} is a date, {y} is a date, and {z} is a number.

Operator Result Type Example Explanation
< Boolean {x} < {y} Whether {x} is less than {y}
<= Boolean {x} <= {y} Whether {x} is less than or equal to {y}
> Boolean {x} > {y} Whether {x} is greater/later than {y}
>= Boolean {x} >= {y} Whether {x} is greater/later than or equals
= Boolean {x} = {y} Whether {x} is equal to {y}
!= Boolean {x} != {y} Whether {x} is not equal to {y}
DaysDiff Number (decimal) {x} daysdiff {y} The days difference between {x} and {y} (can be negative)
MonthsDiff Number (decimal) {x} monthsdiff {y} The months difference between {x} and {y} (can be negative)
YearDiff Number (decimal) {x} yeardiff {y} The year difference between {x} and {y} (can be negative)
- Timespan {x}-{y} Returns a timespan representing the time between x and y.
AddDays Date {x} adddays {z} Adds {z} days to {x}
AddMonths Date {x} addmonths {z} Adds {z} months to {x}
AddYears Date {x} addyears {z} Adds {z} years to {x}
SubDays Date {x} subdays {z} Subtracts {z} days from {x}
SubMonths Date {x} submonths {z} Subtracts {z} months from {x}
SubYears Date {x} subyears {z} Subtracts {z} years from {x}

Text Operators

In the following examples, assume {x} is text.

Operator Result Type Example Explanation
Contains Boolean {x} contains 'a' Whether {x} contains the text a
StartsWith Boolean {x} startswith 'a' Whether {x} starts with the text a
EndsWith Boolean {x} endswith 'a' Whether {x} ends with the text a

Math Operators

Most math operators should work as expected, so knock yourself out.