Script
How to Format Rules with JavaScript Expressions
JavaScript expressions can be used with the following syntax:
In newer versions of Squidex, the user interface has been improved and custom input fields have been introduced which allows selection of the syntax and adds the necessary prefix automatically.
Basic Syntax
The scripting engine supports almost all ES6 features with a few restrictions.
Therefore, it is best to use the Javascript template string syntax and just reference properties directly:
Special Functions
Squidex provides a set of general helper functions for scripting and rule formatting.
A value list can be found in the documentation concerning scripting helper methods here:
Additionally, there are also methods which are only available for rule formatting.
Examples
Resolve References
You can use scripting to resolve references. You must pass over an array of content IDs and a callback (that is invoked) with the resulting list of content items.
Or a single reference:
Resolve References
You can use scripting to resolve assets. You have to pass over an array of asset IDs and a callback (that is invoked) with the resulting list of assets.
Or a single asset:
Conditional Formatting
You can use if-statements and other JavaScript language features for conditional formatting.
In the following example, different payloads have been created, depending on the asset size:
Last updated