Expression language definition
October 26, 2022 ยท View on GitHub
The internal expression engine is Expr. You can find exhaustive documentation on the possibilities of the language at this address.
Supported Literals
- strings - single and double quotes (e.g.
"hello",'hello') - numbers - e.g.
103,2.5 - arrays - e.g.
[1, 2, 3] - maps - e.g.
{foo: "bar"} - booleans -
trueandfalse - nil -
nil
Accessing article properties
Article properties can be accessed by using their name:
Title: Article titleText: Article text descriptionContent: Article HTML contentLink: Article URLMeta["key"]: Metadata valueTags: Array of tags
Supported Operators
Comparison Operators
==(equal)!=(not equal)<(less than)>(greater than)<=(less than or equal to)>=(greater than or equal to)
Logical Operators
notor!andor&&oror||
String Operators
+(concatenation)matches(regex match)contains(string contains)startsWith(has prefix)endsWith(has suffix)toLower(to lower case)toUpper(to upper case)
To test if a string does not match a regex, use the logical not operator in combination with the matches operator:
not (Title matches "^b.+")
You must use parenthesis because the unary operator not has precedence over the binary operator matches.
Example:
'Arthur' + ' ' + 'Dent'
Result will be set to Arthur Dent.
Membership Operators
in(contain)not in(does not contain)
Example:
"test" in Tags
meta.author in ['me', 'other']
Builtin functions
len(length of array or string)all(will returntrueif all element satisfies the predicate)none(will returntrueif all element does NOT satisfies the predicate)any(will returntrueif any element satisfies the predicate)one(will returntrueif exactly ONE element satisfies the predicate)filter(filter array by the predicate)map(map all items with the closure)
Example:
len(Text) > 200
Closures
{...}(closure)
Closures allowed only with builtin functions. To access current item use # symbol.
one(tags, {# == 'test'})