Passing in a Hash instance as kwargs parameters requires the "double splat" prefix

This commit is contained in:
Akira Matsuda 2019-09-05 02:36:17 +09:00
parent 58df38818a
commit 4071115ddd
6 changed files with 10 additions and 10 deletions

View File

@ -166,7 +166,7 @@ module ActionView
def cache(name = {}, options = {}, &block)
if controller.respond_to?(:perform_caching) && controller.perform_caching
name_options = options.slice(:skip_digest, :virtual_path)
safe_concat(fragment_for(cache_fragment_name(name, name_options), options, &block))
safe_concat(fragment_for(cache_fragment_name(name, **name_options), options, &block))
else
yield
end

View File

@ -755,10 +755,10 @@ module ActionView
output = capture(builder, &block)
options[:multipart] ||= builder.multipart?
html_options = html_options_for_form_with(url, model, options)
html_options = html_options_for_form_with(url, model, **options)
form_tag_with_body(html_options, output)
else
html_options = html_options_for_form_with(url, model, options)
html_options = html_options_for_form_with(url, model, **options)
form_tag_html(html_options)
end
end

View File

@ -107,8 +107,8 @@ module ActionView
true
end
def method_missing(called, *args, &block)
tag_string(called, *args, &block)
def method_missing(called, *args, **options, &block)
tag_string(called, *args, **options, &block)
end
end

View File

@ -82,14 +82,14 @@ module ActionView
html_safe_options[name] = ERB::Util.html_escape(value.to_s)
end
end
translation = I18n.translate(scope_key_by_partial(key), html_safe_options.merge(raise: i18n_raise))
translation = I18n.translate(scope_key_by_partial(key), **html_safe_options.merge(raise: i18n_raise))
if translation.respond_to?(:map)
translation.map { |element| element.respond_to?(:html_safe) ? element.html_safe : element }
else
translation.respond_to?(:html_safe) ? translation.html_safe : translation
end
else
I18n.translate(scope_key_by_partial(key), options.merge(raise: i18n_raise))
I18n.translate(scope_key_by_partial(key), **options.merge(raise: i18n_raise))
end
rescue I18n::MissingTranslationData => e
if remaining_defaults.present?

View File

@ -62,7 +62,7 @@ class FormWithActsLikeFormTagTest < FormWithTest
end
def whole_form(action = "http://www.example.com", options = {})
out = form_text(action, options) + hidden_fields(options)
out = form_text(action, **options) + hidden_fields(options)
if block_given?
out << yield << "</form>"
@ -168,7 +168,7 @@ class FormWithActsLikeFormTagTest < FormWithTest
end
class FormWithActsLikeFormForTest < FormWithTest
def form_with(*)
def form_with(*, **)
@output_buffer = super
end

View File

@ -368,7 +368,7 @@ class TextHelperTest < ActionView::TestCase
def test_word_wrap_does_not_modify_the_options_hash
options = { line_width: 15 }
passed_options = options.dup
word_wrap("some text", passed_options)
word_wrap("some text", **passed_options)
assert_equal options, passed_options
end