# If Parser (/placeholders/parsers/ifStatements)



## Usage [#usage]

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

`{if(expression):trueMessage|falseMessage}`

## Expression Operators [#expression-operators]

The following operators are available for creating expressions:

| Operator | Description           | Example  | Meaning                                                  |
| -------- | --------------------- | -------- | -------------------------------------------------------- |
| `==`     | Equality              | `a==a`   | Checks if two values are equal                           |
| `!=`     | Inequality            | `a!=b`   | Checks if two values are not equal                       |
| `>`      | Greater than          | `5>3`    | Checks if first value is greater than second             |
| `<`      | Less than             | `4<8`    | Checks if first value is less than second                |
| `>=`     | Greater than or equal | `10>=10` | Checks if first value is greater than or equal to second |
| `<=`     | Less than or equal    | `5<=6`   | Checks if first value is less than or equal to second    |

## Examples [#examples]

1. Simple comparison:

* Input: `{if(5>3):True|False}`
* Output: `True`

2. Nested conditions:

* Input: `{if({args}==63):You guessed it!|Too {if({args}<63):low|high}, try again.}`
* With args=63: `You guessed it!`
* With args=73: `Too high, try again.`
* With args=14: `Too low, try again.`

3. Using with placeholders:

* Input: `{if({contains(roleId):{member.roles}}):Welcome admin!|Access denied.}`
* Output with admin role: `Welcome admin!`
* Output without admin role: `Access denied.`

## Notes [#notes]

* Expressions can use any valid placeholder values
* Multiple conditions can be nested for complex logic
* The true and false messages are required and must be separated by a pipe (|)
* Whitespace around operators is ignored
