-
Notifications
You must be signed in to change notification settings - Fork 0
Attribute: map
Richard Cowin edited this page Nov 28, 2023
·
5 revisions
The map
is used for a "bind" action
. It provides a mechanism to reduce a value to specific set of discreet values. Unlike the apply
attribute, map
must have a tag
attribute set at the same level. It is not used as an inheritance mechanism.
It is represented as an array of objects that allows the value of the attribute to be transformed. Those mappings each have 2 json keys:
- when - a regex for testing the attribute value against
- value - the new value to be bound to the attribute when conditional is met
{
"source": "expression",
"key": "document.referrer",
"type": "string",
"tag": "referrer.searchEngine",
"map": [
{"when": "google.com", "value": "google"},
{"when": "bing.com", "value": "bing"},
{"when": "search.yahoo", "value": "yahoo"},
{"when": "yandex.com", "value": "yandex"},
{"when": "duckduckgo.com", "value": "duckduckgo"}
]
}
In this example, referrer.searchEngine will only be bound if the document.referrer
matches one of the 5 when
clauses.