Skip to content

Instantly share code, notes, and snippets.

@andrewmp1
Last active December 17, 2015 21:29
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 andrewmp1/5674777 to your computer and use it in GitHub Desktop.
Save andrewmp1/5674777 to your computer and use it in GitHub Desktop.
create an object of helper functions for use w/ ember
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