Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Handlebars helper: Contains
// Handlebars helper: Contains
// check if a value is contained in an array
Handlebars.registerHelper("contains", function( value, array, options ){
// fallback...
array = ( array instanceof Array ) ? array : [array];
return (array.indexOf(value) > -1) ? options.fn( this ) : "";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment