带有混合参数的Ember.js帮助程序

带有混合参数的Ember.js帮助程序,ember.js,handlebars.js,Ember.js,Handlebars.js,我正在使用js routes for Rails,并希望将其与Ember.js结合使用。我编写了一个助手来从js routes提供的全局路由中获取路由,但我似乎无法让它工作 用法:{{route'user\u path'user.id}} 预期收益:/users/123 尝试1: Ember.Handlebars.registerHelper('route', function(path, id) { console.log(path); // returns the path as a

我正在使用js routes for Rails,并希望将其与Ember.js结合使用。我编写了一个助手来从js routes提供的全局路由中获取路由,但我似乎无法让它工作

用法:
{{route'user\u path'user.id}}

预期收益:
/users/123

尝试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);
});
Ember.Handlebars.registerBoundHelper('route', function(path, id) {
    console.log(path); // returns undefined --> Not OK!
    console.log(id); // returns 123 --> OK!
    return Routes[path](id);
});
尝试2:

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);
});
Ember.Handlebars.registerBoundHelper('route', function(path, id) {
    console.log(path); // returns undefined --> Not OK!
    console.log(id); // returns 123 --> OK!
    return Routes[path](id);
});

我怎样才能做到这一点?谢谢

没关系,我自己找到的:

Ember.Handlebars.registerBoundHelper('route', function(context, options) {
    return Routes[options.hash.path](context.id);
});
用法:
{{route this path='user\u path'}}