Skip to main content

Overview

General information

Expression Language is created based on Symfony Expression Language. It is working based on Dynamic Data. The purpose of the Expression Language is to allow users to use expressions for data accessing, data modification, data evaluation:

If for example there is a such dynamic data: Dynamic data JSON

Data Accessing:

  • expression postData.queried_post.post_title will return "Our Products"
  • expression postData.queried_post.products[0].title will return "Pear"

Data Modification:

  • expression upper(postData.queried_post.post_title) will return "OUR PRODUCTS"
  • expression "Price of " ~ postData.queried_post.products[0].title ~ " is " ~ postData.queried_post.products[0].price ~ "$" will return "Price of Pear is 0.48$"

Data Evaluation:

  • expression postData.queried_post.products[0].price > 1 will return "false"
  • expression postData.queried_post.products[0].price > 1 ? "Expensive Product" : "Cheap Product" will return "Cheap Product"

Supported operators

For the full list of available operators, please, refer to the official Expression Language syntax page Here we list the most using operators:

Arithmetic operators

  • + (addition)
  • - (subtraction)
  • * (multiplication)
  • / (division)
  • % (modulus)
  • ** (power)

Bitwise operators

  • & (and)
  • | (or)

Comparison operators

  • == (equal)
  • === (identical)
  • != (not equal)
  • !== (not identical)
  • < (less than)
  • > (greater than)
  • <= (less than or equal to)
  • >= (greater than or equal to)

Logical operators

  • not or !
  • and or &&
  • or or ||

String operators

  • ~ (concatenation)

Array operators

  • in (contain)
  • not in (does not contain)

Ternary operators

  • foo ? 'yes' : 'no'

Built-in functions

We have created many useful functions to be used in expressions. They help to achieve some conditional logic or transform the data.

We can use both the final values and data variables (defined before the data variable with expression) to pass the data inside the functions. Later there will be examples with context given. Context is equivalent of dynamic data in the builder. Context is the object of data variable names and their evaluated values.

info

We can pass both the final value as well as data variable names as arguments for functions!

Arithmetic functions

Array functions

Boolean functions

Multilingual functions

String functions

How to use

Below is the usage example of a data variable type 'expression':

  1. books is a regular JSON value; in this example we modify each item - book - by adding key price;
  2. addPrices is a variable type 'expression';
  3. the expression editor - the place where we wriote our expression
  4. the preview - the result of the expression

Remembering about the flow of data variables, we have used the previously declared variable inside the expression of addPrices variable. In this case the value of books variable was available in the context for 'foreach' function that is used inside the expression.

In this example we also use "closure" function. Its syntax is very similar to arrow functions in JS, we just use "dash" instead of "equal" sign for making the "arrow": ->. As any other function, this one also has arguments. The first one is an iteration item from our example, it is available with o variable. The second argument is optional and it would be an index of the item.