Last active
December 17, 2015 21:29
-
-
Save andrewmp1/5674777 to your computer and use it in GitHub Desktop.
create an object of helper functions for use w/ 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
helpers = function EmberHelpers(App){ | |
var app = App, | |
container = app.__container__; | |
var helper = { | |
routes: function(){ | |
return app.Router.router.recognizer.names; | |
}, | |
lookup = function(path){ | |
return container.lookup(path); | |
}, | |
appController = function(){ | |
return container.lookup('controller:application'); | |
}, | |
path: function(){ | |
return appController.get('currentPath'); | |
}, | |
routeName: function(){ | |
return helper.path().split('.').pop(); | |
}, | |
route: function(){ | |
return container.lookup('route:' + helper.routeName()); | |
} | |
}; | |
return helper; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment