Created
October 4, 2012 19:12
-
-
Save eviltrout/3835764 to your computer and use it in GitHub Desktop.
#unboundIf and #unboundUnless in Ember
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
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