Provide some helpful error messages when link_to is used improperly
This commit is contained in:
parent
42320ade8d
commit
e4b5202238
|
@ -194,8 +194,13 @@ module Middleman
|
||||||
url_arg_index = block_given? ? 0 : 1
|
url_arg_index = block_given? ? 0 : 1
|
||||||
options_index = block_given? ? 1 : 2
|
options_index = block_given? ? 1 : 2
|
||||||
|
|
||||||
|
if block_given? && args.size > 2
|
||||||
|
raise ArgumentError.new("Too many arguments to link_to(url, options={}, &block)")
|
||||||
|
end
|
||||||
|
|
||||||
if url = args[url_arg_index]
|
if url = args[url_arg_index]
|
||||||
options = args[options_index] || {}
|
options = args[options_index] || {}
|
||||||
|
raise ArgumentError.new("Options must be a hash") unless options.is_a?(Hash)
|
||||||
|
|
||||||
# Transform the url through our magic url_for method
|
# Transform the url through our magic url_for method
|
||||||
args[url_arg_index] = url_for(url, options)
|
args[url_arg_index] = url_for(url, options)
|
||||||
|
|
Loading…
Reference in a new issue