Expressions allow manipulating data using functions, like in Excel/Google sheets.
- value
- hasAttribute
- hasProperty
- removeHtmlTags
- trim
- slug
- replace
- lowerCase
- upperCase
- camelCase
- snakeCase
Returns a value of an attribute by name
, channel
and locale
.
Examples:
value("name", null, "en_GB")
=>Ziggy
value("description", "web", "en_GB")
=>Ziggy The Hydra
If name
is not specified, it returns a value of a field from the current rule.
E.g. if a current rule action is:
-
type: set
field: name
scope: web
locale: en_GB
then
expression: 'value()'
is as same as
expression: 'value("name", "web", "en_GB")'
Returns true if an attribute with the given name
, channel
and locale
exists in data.
Examples:
hasAttribute("name", null, "en_GB")
=>true
hasAttribute("~unknown~", "web", "en_GB")
=>false
Parameter | Description | Type |
---|---|---|
name | string | |
channel | string/null | |
locale | string/null |
If name
is not specified, it checks for the attribute from the current rule.
E.g. if a current rule action is:
-
type: set
field: name
scope: web
locale: en_GB
then
expression: 'hasAttribute()'
is as same as
expression: 'hasAttribute("name", "web", "en_GB")'
Returns true if a property with the given name
exists in data.
Examples:
hasProperty("family")
=>true
hasProperty("~unknown~")
=>false
Parameter | Description | Type |
---|---|---|
name | string |
If name
is not specified, it checks for the property from the current rule.
E.g. if a current rule action is:
-
type: set
field: family
then
expression: 'hasProperty()'
is as same as
expression: 'hasProperty("family")'
Remove HTML tags from a string
Examples:
removeHtmlTags("<p>Lorem ipsum <span>dolor sit amet<span>.</p>")
=>Lorem ipsum dolor sit amet.
removeHtmlTags("<p>Lorem ipsum <span>dolor sit amet<span>.</p>", ["span"])
=>Lorem ipsum <span>dolor sit amet<span>.
Parameter | Description | Type |
---|---|---|
string | string | |
allowedTags | Tags which should not be removed | array |
Removes whitespaces (or other characters
) from the beginning and end of a string
Examples:
trim(" How To Raise A Ziggy ")
=>How To Raise A Ziggy
Parameter | Description | Type |
---|---|---|
string | string | |
chars | Characters to remove, by default all whitespaces " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}" | string |
Generates a slug for a string
.
Examples:
slug("How To Raise A Ziggy")
=>How-To-Raise-A-Ziggy
slug("How To Raise A Ziggy", "_")
=>How_To_Raise_A_Ziggy
Parameter | Description | Type |
---|---|---|
string | string | |
separator | Word separator, default: '-' | string |
locale | Locale, e.g. en_GB, de_DE, es_ES | string/null |
Replaces from
with to
in a string
Examples:
replace("Lorem\nipsum\ndolor\nsit\namet", "\n", " ")
=>Lorem ipsum dolor sit amet
Parameter | Description | Type |
---|---|---|
string | string | |
from | string | |
to | string |
Make a string
lowercase
Examples:
lowerCase("How To Raise A Ziggy")
=>how to raise a ziggy
Parameter | Description | Type |
---|---|---|
string | string |
Make a string
UPPERCASE
Examples:
upperCase("How To Raise A Ziggy")
=>HOW TO RAISE A ZIGGY
Parameter | Description | Type |
---|---|---|
string | string |
Make a string
camelCase
Examples:
camelCase("How To Raise A Ziggy")
=>howToRaiseAZiggy
Parameter | Description | Type |
---|---|---|
string | string |
Make a string
snake_case
Examples:
snakeCase("How To Raise A Ziggy")
=>how_to_raise_a_ziggy
Parameter | Description | Type |
---|---|---|
string | string |