Skip to content

Instantly share code, notes, and snippets.

@wiedi
Created June 10, 2014 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wiedi/fb09a0317e0db2caee6a to your computer and use it in GitHub Desktop.
Save wiedi/fb09a0317e0db2caee6a to your computer and use it in GitHub Desktop.
handlebars helper to iterate by sorted object keys
Handlebars.registerHelper('eachSorted', function(context, options) {
var ret = ""
Object.keys(context).sort().forEach(function(key) {
ret = ret + options.fn({key: key, value: context[key]})
})
return ret
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment