actionview 4.2.11.3 → 5.2.7.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionview might be problematic. Click here for more details.

Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +115 -245
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +5 -6
  5. data/lib/action_view/base.rb +38 -28
  6. data/lib/action_view/buffers.rb +3 -1
  7. data/lib/action_view/context.rb +3 -3
  8. data/lib/action_view/dependency_tracker.rb +54 -20
  9. data/lib/action_view/digestor.rb +94 -83
  10. data/lib/action_view/flows.rb +11 -11
  11. data/lib/action_view/gem_version.rb +5 -3
  12. data/lib/action_view/helpers/active_model_helper.rb +17 -11
  13. data/lib/action_view/helpers/asset_tag_helper.rb +244 -62
  14. data/lib/action_view/helpers/asset_url_helper.rb +170 -67
  15. data/lib/action_view/helpers/atom_feed_helper.rb +19 -17
  16. data/lib/action_view/helpers/cache_helper.rb +105 -42
  17. data/lib/action_view/helpers/capture_helper.rb +16 -13
  18. data/lib/action_view/helpers/controller_helper.rb +15 -4
  19. data/lib/action_view/helpers/csp_helper.rb +24 -0
  20. data/lib/action_view/helpers/csrf_helper.rb +7 -5
  21. data/lib/action_view/helpers/date_helper.rb +170 -112
  22. data/lib/action_view/helpers/debug_helper.rb +7 -6
  23. data/lib/action_view/helpers/form_helper.rb +521 -127
  24. data/lib/action_view/helpers/form_options_helper.rb +109 -63
  25. data/lib/action_view/helpers/form_tag_helper.rb +110 -67
  26. data/lib/action_view/helpers/javascript_helper.rb +27 -12
  27. data/lib/action_view/helpers/number_helper.rb +77 -58
  28. data/lib/action_view/helpers/output_safety_helper.rb +36 -4
  29. data/lib/action_view/helpers/record_tag_helper.rb +14 -99
  30. data/lib/action_view/helpers/rendering_helper.rb +6 -5
  31. data/lib/action_view/helpers/sanitize_helper.rb +20 -15
  32. data/lib/action_view/helpers/tag_helper.rb +229 -73
  33. data/lib/action_view/helpers/tags/base.rb +134 -97
  34. data/lib/action_view/helpers/tags/check_box.rb +20 -18
  35. data/lib/action_view/helpers/tags/checkable.rb +4 -2
  36. data/lib/action_view/helpers/tags/collection_check_boxes.rb +12 -33
  37. data/lib/action_view/helpers/tags/collection_helpers.rb +70 -36
  38. data/lib/action_view/helpers/tags/collection_radio_buttons.rb +6 -11
  39. data/lib/action_view/helpers/tags/collection_select.rb +4 -2
  40. data/lib/action_view/helpers/tags/color_field.rb +3 -1
  41. data/lib/action_view/helpers/tags/date_field.rb +2 -0
  42. data/lib/action_view/helpers/tags/date_select.rb +38 -36
  43. data/lib/action_view/helpers/tags/datetime_field.rb +4 -2
  44. data/lib/action_view/helpers/tags/datetime_local_field.rb +2 -0
  45. data/lib/action_view/helpers/tags/datetime_select.rb +2 -0
  46. data/lib/action_view/helpers/tags/email_field.rb +2 -0
  47. data/lib/action_view/helpers/tags/file_field.rb +2 -0
  48. data/lib/action_view/helpers/tags/grouped_collection_select.rb +4 -2
  49. data/lib/action_view/helpers/tags/hidden_field.rb +2 -0
  50. data/lib/action_view/helpers/tags/label.rb +3 -1
  51. data/lib/action_view/helpers/tags/month_field.rb +2 -0
  52. data/lib/action_view/helpers/tags/number_field.rb +2 -0
  53. data/lib/action_view/helpers/tags/password_field.rb +3 -1
  54. data/lib/action_view/helpers/tags/placeholderable.rb +3 -1
  55. data/lib/action_view/helpers/tags/radio_button.rb +7 -5
  56. data/lib/action_view/helpers/tags/range_field.rb +2 -0
  57. data/lib/action_view/helpers/tags/search_field.rb +14 -9
  58. data/lib/action_view/helpers/tags/select.rb +11 -9
  59. data/lib/action_view/helpers/tags/tel_field.rb +2 -0
  60. data/lib/action_view/helpers/tags/text_area.rb +4 -2
  61. data/lib/action_view/helpers/tags/text_field.rb +8 -7
  62. data/lib/action_view/helpers/tags/time_field.rb +2 -0
  63. data/lib/action_view/helpers/tags/time_select.rb +2 -0
  64. data/lib/action_view/helpers/tags/time_zone_select.rb +3 -1
  65. data/lib/action_view/helpers/tags/translator.rb +17 -13
  66. data/lib/action_view/helpers/tags/url_field.rb +2 -0
  67. data/lib/action_view/helpers/tags/week_field.rb +2 -0
  68. data/lib/action_view/helpers/tags.rb +3 -1
  69. data/lib/action_view/helpers/text_helper.rb +55 -36
  70. data/lib/action_view/helpers/translation_helper.rb +74 -32
  71. data/lib/action_view/helpers/url_helper.rb +159 -104
  72. data/lib/action_view/helpers.rb +5 -1
  73. data/lib/action_view/layouts.rb +65 -58
  74. data/lib/action_view/log_subscriber.rb +60 -8
  75. data/lib/action_view/lookup_context.rb +80 -65
  76. data/lib/action_view/model_naming.rb +3 -1
  77. data/lib/action_view/path_set.rb +30 -19
  78. data/lib/action_view/railtie.rb +39 -6
  79. data/lib/action_view/record_identifier.rb +53 -25
  80. data/lib/action_view/renderer/abstract_renderer.rb +21 -15
  81. data/lib/action_view/renderer/partial_renderer/collection_caching.rb +57 -0
  82. data/lib/action_view/renderer/partial_renderer.rb +218 -214
  83. data/lib/action_view/renderer/renderer.rb +8 -6
  84. data/lib/action_view/renderer/streaming_template_renderer.rb +50 -48
  85. data/lib/action_view/renderer/template_renderer.rb +67 -66
  86. data/lib/action_view/rendering.rb +19 -14
  87. data/lib/action_view/routing_url_for.rb +27 -17
  88. data/lib/action_view/tasks/cache_digests.rake +25 -0
  89. data/lib/action_view/template/error.rb +16 -16
  90. data/lib/action_view/template/handlers/builder.rb +10 -11
  91. data/lib/action_view/template/handlers/erb/erubi.rb +83 -0
  92. data/lib/action_view/template/handlers/erb.rb +9 -80
  93. data/lib/action_view/template/handlers/html.rb +11 -0
  94. data/lib/action_view/template/handlers/raw.rb +3 -3
  95. data/lib/action_view/template/handlers.rb +11 -7
  96. data/lib/action_view/template/html.rb +5 -5
  97. data/lib/action_view/template/resolver.rb +140 -115
  98. data/lib/action_view/template/text.rb +8 -9
  99. data/lib/action_view/template/types.rb +18 -18
  100. data/lib/action_view/template.rb +54 -33
  101. data/lib/action_view/test_case.rb +50 -29
  102. data/lib/action_view/testing/resolvers.rb +31 -31
  103. data/lib/action_view/version.rb +3 -1
  104. data/lib/action_view/view_paths.rb +28 -34
  105. data/lib/action_view.rb +8 -7
  106. data/lib/assets/compiled/rails-ujs.js +720 -0
  107. metadata +28 -27
  108. data/lib/action_view/tasks/dependencies.rake +0 -23
@@ -1,4 +1,6 @@
1
- require 'action_view/helpers/tags/checkable'
1
+ # frozen_string_literal: true
2
+
3
+ require "action_view/helpers/tags/checkable"
2
4
 
3
5
  module ActionView
4
6
  module Helpers
@@ -16,7 +18,7 @@ module ActionView
16
18
  options = @options.stringify_keys
17
19
  options["type"] = "checkbox"
18
20
  options["value"] = @checked_value
19
- options["checked"] = "checked" if input_checked?(object, options)
21
+ options["checked"] = "checked" if input_checked?(options)
20
22
 
21
23
  if options["multiple"]
22
24
  add_default_name_and_id_for_value(@checked_value, options)
@@ -38,26 +40,26 @@ module ActionView
38
40
 
39
41
  private
40
42
 
41
- def checked?(value)
42
- case value
43
- when TrueClass, FalseClass
44
- value == !!@checked_value
45
- when NilClass
46
- false
47
- when String
48
- value == @checked_value
49
- else
50
- if value.respond_to?(:include?)
51
- value.include?(@checked_value)
43
+ def checked?(value)
44
+ case value
45
+ when TrueClass, FalseClass
46
+ value == !!@checked_value
47
+ when NilClass
48
+ false
49
+ when String
50
+ value == @checked_value
52
51
  else
53
- value.to_i == @checked_value.to_i
52
+ if value.respond_to?(:include?)
53
+ value.include?(@checked_value)
54
+ else
55
+ value.to_i == @checked_value.to_i
56
+ end
54
57
  end
55
58
  end
56
- end
57
59
 
58
- def hidden_field_for_checkbox(options)
59
- @unchecked_value ? tag("input", options.slice("name", "disabled", "form").merge!("type" => "hidden", "value" => @unchecked_value)) : "".html_safe
60
- end
60
+ def hidden_field_for_checkbox(options)
61
+ @unchecked_value ? tag("input", options.slice("name", "disabled", "form").merge!("type" => "hidden", "value" => @unchecked_value)) : "".html_safe
62
+ end
61
63
  end
62
64
  end
63
65
  end
@@ -1,13 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionView
2
4
  module Helpers
3
5
  module Tags # :nodoc:
4
6
  module Checkable # :nodoc:
5
- def input_checked?(object, options)
7
+ def input_checked?(options)
6
8
  if options.has_key?("checked")
7
9
  checked = options.delete "checked"
8
10
  checked == true || checked == "checked"
9
11
  else
10
- checked?(value(object))
12
+ checked?(value)
11
13
  end
12
14
  end
13
15
  end
@@ -1,4 +1,6 @@
1
- require 'action_view/helpers/tags/collection_helpers'
1
+ # frozen_string_literal: true
2
+
3
+ require "action_view/helpers/tags/collection_helpers"
2
4
 
3
5
  module ActionView
4
6
  module Helpers
@@ -7,50 +9,27 @@ module ActionView
7
9
  include CollectionHelpers
8
10
 
9
11
  class CheckBoxBuilder < Builder # :nodoc:
10
- def check_box(extra_html_options={})
12
+ def check_box(extra_html_options = {})
11
13
  html_options = extra_html_options.merge(@input_html_options)
14
+ html_options[:multiple] = true
15
+ html_options[:skip_default_ids] = false
12
16
  @template_object.check_box(@object_name, @method_name, html_options, @value, nil)
13
17
  end
14
18
  end
15
19
 
16
20
  def render(&block)
17
- rendered_collection = render_collection do |item, value, text, default_html_options|
18
- default_html_options[:multiple] = true
19
- builder = instantiate_builder(CheckBoxBuilder, item, value, text, default_html_options)
20
-
21
- if block_given?
22
- @template_object.capture(builder, &block)
23
- else
24
- render_component(builder)
25
- end
26
- end
27
-
28
- # Append a hidden field to make sure something will be sent back to the
29
- # server if all check boxes are unchecked.
30
- if @options.fetch(:include_hidden, true)
31
- rendered_collection + hidden_field
32
- else
33
- rendered_collection
34
- end
21
+ render_collection_for(CheckBoxBuilder, &block)
35
22
  end
36
23
 
37
24
  private
38
25
 
39
- def render_component(builder)
40
- builder.check_box + builder.label
41
- end
42
-
43
- def hidden_field
44
- hidden_name = @html_options[:name]
45
-
46
- hidden_name ||= if @options.has_key?(:index)
47
- "#{tag_name_with_index(@options[:index])}[]"
48
- else
49
- "#{tag_name}[]"
26
+ def render_component(builder)
27
+ builder.check_box + builder.label
50
28
  end
51
29
 
52
- @template_object.hidden_field_tag(hidden_name, "", id: nil)
53
- end
30
+ def hidden_field_name
31
+ "#{super}[]"
32
+ end
54
33
  end
55
34
  end
56
35
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionView
2
4
  module Helpers
3
5
  module Tags # :nodoc:
@@ -17,8 +19,10 @@ module ActionView
17
19
  @input_html_options = input_html_options
18
20
  end
19
21
 
20
- def label(label_html_options={}, &block)
22
+ def label(label_html_options = {}, &block)
21
23
  html_options = @input_html_options.slice(:index, :namespace).merge(label_html_options)
24
+ html_options[:for] ||= @input_html_options[:id] if @input_html_options[:id]
25
+
22
26
  @template_object.label(@object_name, @sanitized_attribute_name, @text, html_options, &block)
23
27
  end
24
28
  end
@@ -34,51 +38,81 @@ module ActionView
34
38
 
35
39
  private
36
40
 
37
- def instantiate_builder(builder_class, item, value, text, html_options)
38
- builder_class.new(@template_object, @object_name, @method_name, item,
39
- sanitize_attribute_name(value), text, value, html_options)
40
- end
41
+ def instantiate_builder(builder_class, item, value, text, html_options)
42
+ builder_class.new(@template_object, @object_name, @method_name, item,
43
+ sanitize_attribute_name(value), text, value, html_options)
44
+ end
41
45
 
42
- # Generate default options for collection helpers, such as :checked and
43
- # :disabled.
44
- def default_html_options_for_collection(item, value) #:nodoc:
45
- html_options = @html_options.dup
46
+ # Generate default options for collection helpers, such as :checked and
47
+ # :disabled.
48
+ def default_html_options_for_collection(item, value)
49
+ html_options = @html_options.dup
46
50
 
47
- [:checked, :selected, :disabled, :readonly].each do |option|
48
- current_value = @options[option]
49
- next if current_value.nil?
51
+ [:checked, :selected, :disabled, :readonly].each do |option|
52
+ current_value = @options[option]
53
+ next if current_value.nil?
50
54
 
51
- accept = if current_value.respond_to?(:call)
52
- current_value.call(item)
53
- else
54
- Array(current_value).map(&:to_s).include?(value.to_s)
55
- end
55
+ accept = if current_value.respond_to?(:call)
56
+ current_value.call(item)
57
+ else
58
+ Array(current_value).map(&:to_s).include?(value.to_s)
59
+ end
56
60
 
57
- if accept
58
- html_options[option] = true
59
- elsif option == :checked
60
- html_options[option] = false
61
+ if accept
62
+ html_options[option] = true
63
+ elsif option == :checked
64
+ html_options[option] = false
65
+ end
61
66
  end
67
+
68
+ html_options[:object] = @object
69
+ html_options
62
70
  end
63
71
 
64
- html_options[:object] = @object
65
- html_options
66
- end
72
+ def sanitize_attribute_name(value)
73
+ "#{sanitized_method_name}_#{sanitized_value(value)}"
74
+ end
67
75
 
68
- def sanitize_attribute_name(value) #:nodoc:
69
- "#{sanitized_method_name}_#{sanitized_value(value)}"
70
- end
76
+ def render_collection
77
+ @collection.map do |item|
78
+ value = value_for_collection(item, @value_method)
79
+ text = value_for_collection(item, @text_method)
80
+ default_html_options = default_html_options_for_collection(item, value)
81
+ additional_html_options = option_html_attributes(item)
82
+
83
+ yield item, value, text, default_html_options.merge(additional_html_options)
84
+ end.join.html_safe
85
+ end
71
86
 
72
- def render_collection #:nodoc:
73
- @collection.map do |item|
74
- value = value_for_collection(item, @value_method)
75
- text = value_for_collection(item, @text_method)
76
- default_html_options = default_html_options_for_collection(item, value)
77
- additional_html_options = option_html_attributes(item)
87
+ def render_collection_for(builder_class, &block)
88
+ options = @options.stringify_keys
89
+ rendered_collection = render_collection do |item, value, text, default_html_options|
90
+ builder = instantiate_builder(builder_class, item, value, text, default_html_options)
78
91
 
79
- yield item, value, text, default_html_options.merge(additional_html_options)
80
- end.join.html_safe
81
- end
92
+ if block_given?
93
+ @template_object.capture(builder, &block)
94
+ else
95
+ render_component(builder)
96
+ end
97
+ end
98
+
99
+ # Prepend a hidden field to make sure something will be sent back to the
100
+ # server if all radio buttons are unchecked.
101
+ if options.fetch("include_hidden", true)
102
+ hidden_field + rendered_collection
103
+ else
104
+ rendered_collection
105
+ end
106
+ end
107
+
108
+ def hidden_field
109
+ hidden_name = @html_options[:name] || hidden_field_name
110
+ @template_object.hidden_field_tag(hidden_name, "", id: nil)
111
+ end
112
+
113
+ def hidden_field_name
114
+ "#{tag_name(false, @options[:index])}"
115
+ end
82
116
  end
83
117
  end
84
118
  end
@@ -1,4 +1,6 @@
1
- require 'action_view/helpers/tags/collection_helpers'
1
+ # frozen_string_literal: true
2
+
3
+ require "action_view/helpers/tags/collection_helpers"
2
4
 
3
5
  module ActionView
4
6
  module Helpers
@@ -7,22 +9,15 @@ module ActionView
7
9
  include CollectionHelpers
8
10
 
9
11
  class RadioButtonBuilder < Builder # :nodoc:
10
- def radio_button(extra_html_options={})
12
+ def radio_button(extra_html_options = {})
11
13
  html_options = extra_html_options.merge(@input_html_options)
14
+ html_options[:skip_default_ids] = false
12
15
  @template_object.radio_button(@object_name, @method_name, @value, html_options)
13
16
  end
14
17
  end
15
18
 
16
19
  def render(&block)
17
- render_collection do |item, value, text, default_html_options|
18
- builder = instantiate_builder(RadioButtonBuilder, item, value, text, default_html_options)
19
-
20
- if block_given?
21
- @template_object.capture(builder, &block)
22
- else
23
- render_component(builder)
24
- end
25
- end
20
+ render_collection_for(RadioButtonBuilder, &block)
26
21
  end
27
22
 
28
23
  private
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionView
2
4
  module Helpers
3
5
  module Tags # :nodoc:
@@ -13,8 +15,8 @@ module ActionView
13
15
 
14
16
  def render
15
17
  option_tags_options = {
16
- :selected => @options.fetch(:selected) { value(@object) },
17
- :disabled => @options[:disabled]
18
+ selected: @options.fetch(:selected) { value },
19
+ disabled: @options[:disabled]
18
20
  }
19
21
 
20
22
  select_content_tag(
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionView
2
4
  module Helpers
3
5
  module Tags # :nodoc:
4
6
  class ColorField < TextField # :nodoc:
5
7
  def render
6
8
  options = @options.stringify_keys
7
- options["value"] ||= validate_color_string(value(object))
9
+ options["value"] ||= validate_color_string(value)
8
10
  @options = options
9
11
  super
10
12
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionView
2
4
  module Helpers
3
5
  module Tags # :nodoc:
@@ -1,4 +1,6 @@
1
- require 'active_support/core_ext/time/calculations'
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/core_ext/time/calculations"
2
4
 
3
5
  module ActionView
4
6
  module Helpers
@@ -16,56 +18,56 @@ module ActionView
16
18
 
17
19
  class << self
18
20
  def select_type
19
- @select_type ||= self.name.split("::").last.sub("Select", "").downcase
21
+ @select_type ||= name.split("::").last.sub("Select", "").downcase
20
22
  end
21
23
  end
22
24
 
23
25
  private
24
26
 
25
- def select_type
26
- self.class.select_type
27
- end
27
+ def select_type
28
+ self.class.select_type
29
+ end
28
30
 
29
- def datetime_selector(options, html_options)
30
- datetime = options.fetch(:selected) { value(object) || default_datetime(options) }
31
- @auto_index ||= nil
31
+ def datetime_selector(options, html_options)
32
+ datetime = options.fetch(:selected) { value || default_datetime(options) }
33
+ @auto_index ||= nil
32
34
 
33
- options = options.dup
34
- options[:field_name] = @method_name
35
- options[:include_position] = true
36
- options[:prefix] ||= @object_name
37
- options[:index] = @auto_index if @auto_index && !options.has_key?(:index)
35
+ options = options.dup
36
+ options[:field_name] = @method_name
37
+ options[:include_position] = true
38
+ options[:prefix] ||= @object_name
39
+ options[:index] = @auto_index if @auto_index && !options.has_key?(:index)
38
40
 
39
- DateTimeSelector.new(datetime, options, html_options)
40
- end
41
+ DateTimeSelector.new(datetime, options, html_options)
42
+ end
41
43
 
42
- def default_datetime(options)
43
- return if options[:include_blank] || options[:prompt]
44
+ def default_datetime(options)
45
+ return if options[:include_blank] || options[:prompt]
44
46
 
45
- case options[:default]
46
- when nil
47
- Time.current
48
- when Date, Time
49
- options[:default]
50
- else
51
- default = options[:default].dup
47
+ case options[:default]
48
+ when nil
49
+ Time.current
50
+ when Date, Time
51
+ options[:default]
52
+ else
53
+ default = options[:default].dup
52
54
 
53
- # Rename :minute and :second to :min and :sec
54
- default[:min] ||= default[:minute]
55
- default[:sec] ||= default[:second]
55
+ # Rename :minute and :second to :min and :sec
56
+ default[:min] ||= default[:minute]
57
+ default[:sec] ||= default[:second]
56
58
 
57
- time = Time.current
59
+ time = Time.current
58
60
 
59
- [:year, :month, :day, :hour, :min, :sec].each do |key|
60
- default[key] ||= time.send(key)
61
- end
61
+ [:year, :month, :day, :hour, :min, :sec].each do |key|
62
+ default[key] ||= time.send(key)
63
+ end
62
64
 
63
- Time.utc(
64
- default[:year], default[:month], default[:day],
65
- default[:hour], default[:min], default[:sec]
66
- )
65
+ Time.utc(
66
+ default[:year], default[:month], default[:day],
67
+ default[:hour], default[:min], default[:sec]
68
+ )
69
+ end
67
70
  end
68
- end
69
71
  end
70
72
  end
71
73
  end
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionView
2
4
  module Helpers
3
5
  module Tags # :nodoc:
4
6
  class DatetimeField < TextField # :nodoc:
5
7
  def render
6
8
  options = @options.stringify_keys
7
- options["value"] ||= format_date(value(object))
9
+ options["value"] ||= format_date(value)
8
10
  options["min"] = format_date(datetime_value(options["min"]))
9
11
  options["max"] = format_date(datetime_value(options["max"]))
10
12
  @options = options
@@ -14,7 +16,7 @@ module ActionView
14
16
  private
15
17
 
16
18
  def format_date(value)
17
- value.try(:strftime, "%Y-%m-%dT%T.%L%z")
19
+ raise NotImplementedError
18
20
  end
19
21
 
20
22
  def datetime_value(value)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionView
2
4
  module Helpers
3
5
  module Tags # :nodoc:
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionView
2
4
  module Helpers
3
5
  module Tags # :nodoc:
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionView
2
4
  module Helpers
3
5
  module Tags # :nodoc:
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionView
2
4
  module Helpers
3
5
  module Tags # :nodoc:
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionView
2
4
  module Helpers
3
5
  module Tags # :nodoc:
@@ -15,8 +17,8 @@ module ActionView
15
17
 
16
18
  def render
17
19
  option_tags_options = {
18
- :selected => @options.fetch(:selected) { value(@object) },
19
- :disabled => @options[:disabled]
20
+ selected: @options.fetch(:selected) { value },
21
+ disabled: @options[:disabled]
20
22
  }
21
23
 
22
24
  select_content_tag(
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionView
2
4
  module Helpers
3
5
  module Tags # :nodoc:
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionView
2
4
  module Helpers
3
5
  module Tags # :nodoc:
@@ -17,7 +19,7 @@ module ActionView
17
19
  method_and_value = @tag_value.present? ? "#{@method_name}.#{@tag_value}" : @method_name
18
20
 
19
21
  content ||= Translator
20
- .new(object, @object_name, method_and_value, "helpers.label")
22
+ .new(object, @object_name, method_and_value, scope: "helpers.label")
21
23
  .translate
22
24
  content ||= @method_name.humanize
23
25
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionView
2
4
  module Helpers
3
5
  module Tags # :nodoc:
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionView
2
4
  module Helpers
3
5
  module Tags # :nodoc:
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionView
2
4
  module Helpers
3
5
  module Tags # :nodoc:
4
6
  class PasswordField < TextField # :nodoc:
5
7
  def render
6
- @options = {:value => nil}.merge!(@options)
8
+ @options = { value: nil }.merge!(@options)
7
9
  super
8
10
  end
9
11
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionView
2
4
  module Helpers
3
5
  module Tags # :nodoc:
@@ -10,7 +12,7 @@ module ActionView
10
12
  method_and_value = tag_value.is_a?(TrueClass) ? @method_name : "#{@method_name}.#{tag_value}"
11
13
 
12
14
  placeholder ||= Tags::Translator
13
- .new(object, @object_name, method_and_value, "helpers.placeholder")
15
+ .new(object, @object_name, method_and_value, scope: "helpers.placeholder")
14
16
  .translate
15
17
  placeholder ||= @method_name.humanize
16
18
  @options[:placeholder] = placeholder
@@ -1,4 +1,6 @@
1
- require 'action_view/helpers/tags/checkable'
1
+ # frozen_string_literal: true
2
+
3
+ require "action_view/helpers/tags/checkable"
2
4
 
3
5
  module ActionView
4
6
  module Helpers
@@ -15,16 +17,16 @@ module ActionView
15
17
  options = @options.stringify_keys
16
18
  options["type"] = "radio"
17
19
  options["value"] = @tag_value
18
- options["checked"] = "checked" if input_checked?(object, options)
20
+ options["checked"] = "checked" if input_checked?(options)
19
21
  add_default_name_and_id_for_value(@tag_value, options)
20
22
  tag("input", options)
21
23
  end
22
24
 
23
25
  private
24
26
 
25
- def checked?(value)
26
- value.to_s == @tag_value.to_s
27
- end
27
+ def checked?(value)
28
+ value.to_s == @tag_value.to_s
29
+ end
28
30
  end
29
31
  end
30
32
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionView
2
4
  module Helpers
3
5
  module Tags # :nodoc:
@@ -1,20 +1,25 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionView
2
4
  module Helpers
3
5
  module Tags # :nodoc:
4
6
  class SearchField < TextField # :nodoc:
5
7
  def render
6
- super do |options|
7
- if options["autosave"]
8
- if options["autosave"] == true
9
- options["autosave"] = request.host.split(".").reverse.join(".")
10
- end
11
- options["results"] ||= 10
12
- end
8
+ options = @options.stringify_keys
13
9
 
14
- if options["onsearch"]
15
- options["incremental"] = true unless options.has_key?("incremental")
10
+ if options["autosave"]
11
+ if options["autosave"] == true
12
+ options["autosave"] = request.host.split(".").reverse.join(".")
16
13
  end
14
+ options["results"] ||= 10
17
15
  end
16
+
17
+ if options["onsearch"]
18
+ options["incremental"] = true unless options.has_key?("incremental")
19
+ end
20
+
21
+ @options = options
22
+ super
18
23
  end
19
24
  end
20
25
  end