Skip to content

Instantly share code, notes, and snippets.

@eviltrout
Created October 4, 2012 19:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eviltrout/3835764 to your computer and use it in GitHub Desktop.
Save eviltrout/3835764 to your computer and use it in GitHub Desktop.
#unboundIf and #unboundUnless in Ember
Ember.Handlebars.registerHelper 'unboundIf', (property, options) ->
context = (options.contexts && options.contexts[0]) || this
normalized = Ember.Handlebars.normalizePath(context, property, options.data)
if (Ember.get(normalized.root,normalized.path,options))
return options.fn(context,property)
else
return options.inverse(context,property)
Ember.Handlebars.registerHelper 'unboundUnless', (property, options) ->
context = (options.contexts && options.contexts[0]) || this
normalized = Ember.Handlebars.normalizePath(context, property, options.data)
if (Ember.get(normalized.root,normalized.path,options))
return options.inverse(context,property)
else
return options.fn(context,property)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment