Template Language
Template Language (GTL) allows using variables, functions and conditions in any report text input fields and compiles those expressions into resulting values.
Example
Example with actual data
Syntax
Two possible syntaxes parsed by GTL:
Expressions
Conditions
Expressions
Any text placed between {{
and }}
is considered an Expression. Expression is a mathematical or logical operation that returns a value. For example, this {{ 10 }}
is an expression that returns the number 10. It is possible to use operators, {{ 10 + 5 }}
will return 15. Logical operators are also supported, {{ 10 > 5 }}
will return true
. Here is a list of supported operators:
+
-
*
/
%
=
!=
>
<
>=
<=
Expression can also contain variables, that are defined in the current context. For example,
{{ file.name }}
will return the name of the file, if the file object is defined.
Expression Functions
But the most powerful feature of the expressions is the ability to call functions. These are predefined aggregation functions, that fetch data from the database and return the result. For example,
{{ count('files') }}
will return the number of files in the database.
Here is a list of supported functions:
count
sum
avg
max
min
median
Those functions support the following parameters:
Dataset name - the name of the dataset to fetch data from. Possible values are:
files
,trustees
,connectors
,agents
,activities
.GQL - the GQL query to filter the data. For example,
fileType=doc OR fileType=txt
will return only files with thedoc
ortxt
file type.Attribute - the attribute to aggregate. All functions, except
count
, require this parameter. For example:sum('files', 'fileType=doc OR fileType=txt', 'contentLength')
will return the sum of the sizes of all files with thedoc
ortxt
file type.
Conditions
Conditions are useful when you want to display different text based on some condition. Example:
else
clause is optional and can be omitted:
The if
statement is followed by a condition in parentheses. The condition must be any expression that returns a boolean value.
Last updated
Was this helpful?