GitHub Download

{{#contains}} helper

If you need to check if some value exists in a given string which contains values separated by comma - use the {{#contains}} helper.

Syntax:

{{#contains valueToCheck valueToSearch}}
// if the valueToCheck exists inside the valueToSearch
{{/contains}}

Examples:

{{#contains 'abc' 'abc,def'}}
abc,def contains abc
{{/contains}}

{{#contains 1 'a,1,2,d,e,f'}}
a,1,2,d,e,f contains 1
{{/contains}}

As you can see above - it also supports numbers, so if your string contains numbers you haven't to cast your first argument to string.

Examples output:

abc,def contains abc
a,1,2,d,e,f contains 1

 

Subscribe

Get the latest Publii news, updates and more delivered directly to your email inbox

You can change your mind at any time by clicking the unsubscribe link in the footer of any email you receive from us, or by contacting us at contact@tidycustoms.net. By clicking below, you agree that we may process your information in accordance with our Privacy Policy.