13 lines
410 B
CoffeeScript
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}'")
|