Liquid
How to format rules with Liquid templates.
You can use Liquid templates using the following syntax:
1
Liquid(<YOUR_SCRIPT>)
Copied!

Basic syntax

The liquid syntax is documented by shopify at https://shopify.github.io/liquid/

Special extensions

Squidex provides special extensions.

Tags

reference

Resolves a content by ID and saves the content in a variable.
1
// Input
2
3
{% for id in event.data.references.iv %}
4
{% reference 'ref', id %}
5
Text: {{ ref.data.field1.iv }} {{ ref.data.field2.iv }} {{ ref.id }}
6
{% endfor %}
7
8
9
// Output
10
Text: Content1_Field1 Content1_Field2 Content1_ID
11
Text: Content2_Field1 Content2_Field2 Content1_ID
Copied!

asset

Resolves a asset by ID and saves the asset in a variable.
1
// Input
2
3
{% for id in event.data.assets.iv %}
4
{% asset 'ref', id %}
5
Text: {{ ref.fileName }} {{ ref.id }}
6
{% endfor %}
7
8
// Output
9
Text: Asset1_FileName Asset1_ID
10
Text: Asset2_FileName Asset2_ID
Copied!

Filters

format_date

Formats a date using a specified pattern.
1
{{event.timestamp | format_date: 'yyyy-MM-dd-hh-mm-ss'}}
Copied!

timestamp

Returns the number of milliseconds between 1970/1/1 and a given date.
1
{{event.timestamp | timestamp}}
Copied!

timestamp_sec

Returns the number of seconds between 1970/1/1 and a given date.
1
{{event.timestamp_sec | timestamp}}
Copied!

escape

Escapes a value to be a valid JSON string.
1
{{event.user.name | escape}}
Copied!

html2text

Converts a HTML string to plain text.
1
{{event.data.body.iv | html2text}}
Copied!

markdown2text

Converts a markdown string to plain text.
1
{{event.data.body.iv | html2text}}
Copied!

md5

Calculate the MD5 hash from a given string. Use this method for hashing passwords, when backwards compatibility is important
1
{{event.data.password.iv | md5}}
Copied!

sha256

Calculate the SHA256 hash from a given string. Use this method for hashing passwords.
1
{{event.data.password.iv | sha256}}
Copied!

slugify

Calculates the slug of a text by removing all special characters and whitespaces to create a friendly term that can be used for SEO-friendly URLs.
1
{{event.data.title.iv | slugify}}
Copied!

trim

Same as strip. Removes all whitespace (tabs, spaces, and newlines) from both the left and right sides of a string. It does not affect spaces between words.
Last modified 3mo ago