Skip to content

Instantly share code, notes, and snippets.

@jwietelmann
Created September 25, 2012 18:26
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 jwietelmann/3783569 to your computer and use it in GitHub Desktop.
Save jwietelmann/3783569 to your computer and use it in GitHub Desktop.
Shared Handlebars.js helpers for both Node.js and web client
helpers =
test: (templateName) ->
"THIS IS A TEST"
addHelpers = (handlebars) -> handlebars.registerHelper name, fn for name, fn of helpers
# server-side
if module? && module.exports?
module.exports = addHelpers
# client-side
else if Handlebars
addHelpers Handlebars
# oh-no-what-have-i-done-side
else
throw "Problem adding Handlebars helpers"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment