I'm trying to build a helper to resolve ulr routes, like this:
Handlebars.registerHelper('rails_route', function(route, options) {
var fn = Routes[route];
if(typeof fn === 'function') {
var opts = {};
for (var key in options.hash) {
var value = options.hash[key];
opts[key] = options.fn(value); // Uncaught TypeError: Object #<Object> has no method 'fn'
}
return fn(opts);
}
return "#";
});
And i call this helper like this:
<ul class="dropdown-menu">
{{#each membership in controllers.currentUser.user.memberships}}
<li>
<a href="{{rails_route root_path firm_id=membership.firm.id }}">{{membership.firm.name}}</a>
</li>
{{/each}}
</ul>
I need to evaluate "membership.firm.id" but i alaways get "Uncaught TypeError: Object # has no method 'fn' ". What is the right way to do this?