You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
637 B
25 lines
637 B
Rails.application.assets.context_class.class_eval do
|
|
def path(name, params=[], **options)
|
|
helper = "#{name}_path"
|
|
names = []
|
|
replace = []
|
|
params.each_with_index do |n, p|
|
|
arg = "__p#{p}__"
|
|
names << arg
|
|
replace << [arg, "\#{#{n}}"]
|
|
end
|
|
query_params = options.delete :params
|
|
unless query_params.nil?
|
|
query_params.each_with_index do |n, p|
|
|
arg = "__q#{p}__"
|
|
names << arg
|
|
replace << [arg, "\#{#{n}}"]
|
|
options[n] = arg
|
|
end
|
|
end
|
|
|
|
path = Rails.application.routes.url_helpers.send helper, *names, **options
|
|
replace.each { |p, n| path.sub! p, n }
|
|
"#{config.relative_url_root}#{path}"
|
|
end
|
|
end
|
|
|