I'm using js-routes for Rails and would like to use this in combination with Ember.js. I wrote a helper to fetch the routes from the global Routes as provided by js-routes, but I can't seem to get it working.
Usage: {{route 'user_path' user.id}}
Expected return: /users/123
Attempt 1:
Ember.Handlebars.registerHelper('route', function(path, id) {
console.log(path); // returns the path as a string --> OK!
console.log(id); // returns the string 'user.id' --> Not ok!
return Routes[path](id);
});
Attempt 2:
Ember.Handlebars.registerBoundHelper('route', function(path, id) {
console.log(path); // returns undefined --> Not OK!
console.log(id); // returns 123 --> OK!
return Routes[path](id);
});
How can I achieve this? Thanks!