Created
January 30, 2014 06:08
-
-
Save tracend/8703397 to your computer and use it in GitHub Desktop.
Handlebars helper: Contains
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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