Skip to content

Instantly share code, notes, and snippets.

@tracend
Created January 30, 2014 06:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tracend/8703397 to your computer and use it in GitHub Desktop.
Save tracend/8703397 to your computer and use it in GitHub Desktop.
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