# Includes Parser (/placeholders/parsers/includes)



## Usage [#usage]

To use the parser, insert the following syntax in your text:

`{includes(<search>):<payload>}`

Aliases: `in`, `contains`, `contain` - all behave the same way.

### Behaviour [#behaviour]

* If the payload is a JSON array (e.g. `["a","b"]`), the parser checks whether any element strictly matches the search value after coercing array elements to strings. This means numeric array elements like `63` will match the search value `"63"`.
* If the payload is not valid JSON, the parser falls back to a substring check using `String.prototype.includes` on the payload string.

## Examples [#examples]

### 1. Array membership (JSON array payload) [#1-array-membership-json-array-payload]

* Input: `{includes(apple):["apple","banana"]}`
* Output: `true`

### 2. String contains (plain string payload) [#2-string-contains-plain-string-payload]

* Input: `{includes(world):Hello world}`
* Output: `true`

### 3. Numeric match with type coercion [#3-numeric-match-with-type-coercion]

* Input: `{includes(63):[63,72,81]}`
* Output: `true`

### 4. Using placeholders [#4-using-placeholders]

* Input: `{includes(123):{member.roles}}`
* Assuming `member.roles` is `"[\"123\",\"456\"]"` (a JSON array string)
* Output: `true`

## Notes [#notes]

* When given a JSON array payload, elements are compared by converting each element to a string and doing a strict string equality check against the search value.
* When the payload is not a JSON array, a substring `includes` check is performed on the payload string.
* Whitespace around the search parameter is trimmed before comparison.
