Files
mozo-backend/app/assets/javascripts/supplier/app/helpers/route_link_helper.js.coffee
T
2014-04-18 20:38:13 +02:00

13 lines
410 B
CoffeeScript

Ember.Handlebars.registerHelper 'path', (route, params..., options)->
route_method = Routes["#{route}_path"]
throw "Route #{route} cannout be found" unless route_method
mapped_options = {}
for k, v of options.hash
mapped_options[k] = Ember.Handlebars.get(this, v, options) || v
params.push mapped_options
path = route_method.apply(this, params)
new Handlebars.SafeString("href='#{path}'")