Choose formatter
Select one of several outputs based on the value of a placeholder.
Read time 2 minutesLast updated 13 days ago
Select one of several outputs based on the value of a placeholder.
The Choose formatter adds branching logic to a Smart String: it matches the placeholder value against a set of options and outputs the corresponding choice. Apply it explicitly with the name .
chooseAnatomy of the choose formatter syntax.
The value is converted to a string with ToString and matched against the options, so you can use it on any type, including numbers, booleans, strings, or enums. is also supported.
nullTo supply a fallback output for any values that don't match any of the choices, add an extra output option at the end of the outputs segment.
Choices are case-sensitive by default, but you can configure this behavior with the case sensitivity setting. Refer to Smart Strings settings reference for information on the different settings and how to enable them.
Smart String | Argument | Result |
|---|---|---|
| | two |
| | other |
| | yes |
| | NULL |
| | How is he? |
| | It is the weekend. |