Radical Design Course by Jack McDade

From the creator of Statamic

Learn how to make your websites standout and be remembered.

Just exceptional. Thank you so much, Jack, you smashed it.

— Hugo, Developer

in_array Modifier

Check if an array contains a specific value. Returns true if a match is found.

The first parameter is the "needle" to find in the "haystack". It will read from the context if there is a matching variable, otherwise it will use the parameter as the value. You can pass multiple arguments.

shopping_list:
- eggs
- flour
- beef jerky
want: eggs
{{ if (shopping_list | in_array('flour')) }} GOT IT! {{ /if }}
{{ if (shopping_list | in_array('want')) }} GOT EM! {{ /if }}
{{ if (shopping_list | in_array('eggs', 'flour')) }} YES I DID NOT FORGET! {{ /if }}
GOT IT!
GOT EM!
YES I DID NOT FORGET!
Docs feedback

Submit improvements, related content, or suggestions through Github.

Betterify this page →