actionview 5.1.7 → 5.2.0.beta1

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 (107) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +27 -275
  3. data/README.rdoc +1 -1
  4. data/lib/action_view.rb +3 -2
  5. data/lib/action_view/base.rb +8 -10
  6. data/lib/action_view/buffers.rb +2 -0
  7. data/lib/action_view/context.rb +2 -2
  8. data/lib/action_view/dependency_tracker.rb +2 -0
  9. data/lib/action_view/digestor.rb +6 -12
  10. data/lib/action_view/flows.rb +2 -0
  11. data/lib/action_view/gem_version.rb +5 -3
  12. data/lib/action_view/helpers.rb +2 -0
  13. data/lib/action_view/helpers/active_model_helper.rb +9 -3
  14. data/lib/action_view/helpers/asset_tag_helper.rb +79 -22
  15. data/lib/action_view/helpers/asset_url_helper.rb +13 -11
  16. data/lib/action_view/helpers/atom_feed_helper.rb +3 -1
  17. data/lib/action_view/helpers/cache_helper.rb +24 -14
  18. data/lib/action_view/helpers/capture_helper.rb +9 -7
  19. data/lib/action_view/helpers/controller_helper.rb +3 -1
  20. data/lib/action_view/helpers/csrf_helper.rb +4 -2
  21. data/lib/action_view/helpers/date_helper.rb +5 -3
  22. data/lib/action_view/helpers/debug_helper.rb +3 -1
  23. data/lib/action_view/helpers/form_helper.rb +43 -60
  24. data/lib/action_view/helpers/form_options_helper.rb +9 -7
  25. data/lib/action_view/helpers/form_tag_helper.rb +20 -11
  26. data/lib/action_view/helpers/javascript_helper.rb +5 -3
  27. data/lib/action_view/helpers/number_helper.rb +2 -0
  28. data/lib/action_view/helpers/output_safety_helper.rb +2 -0
  29. data/lib/action_view/helpers/record_tag_helper.rb +3 -1
  30. data/lib/action_view/helpers/rendering_helper.rb +4 -1
  31. data/lib/action_view/helpers/sanitize_helper.rb +3 -1
  32. data/lib/action_view/helpers/tag_helper.rb +2 -2
  33. data/lib/action_view/helpers/tags.rb +3 -1
  34. data/lib/action_view/helpers/tags/base.rb +12 -10
  35. data/lib/action_view/helpers/tags/check_box.rb +3 -1
  36. data/lib/action_view/helpers/tags/checkable.rb +4 -2
  37. data/lib/action_view/helpers/tags/collection_check_boxes.rb +2 -0
  38. data/lib/action_view/helpers/tags/collection_helpers.rb +2 -0
  39. data/lib/action_view/helpers/tags/collection_radio_buttons.rb +2 -0
  40. data/lib/action_view/helpers/tags/collection_select.rb +3 -1
  41. data/lib/action_view/helpers/tags/color_field.rb +3 -1
  42. data/lib/action_view/helpers/tags/date_field.rb +2 -0
  43. data/lib/action_view/helpers/tags/date_select.rb +3 -1
  44. data/lib/action_view/helpers/tags/datetime_field.rb +3 -1
  45. data/lib/action_view/helpers/tags/datetime_local_field.rb +2 -0
  46. data/lib/action_view/helpers/tags/datetime_select.rb +2 -0
  47. data/lib/action_view/helpers/tags/email_field.rb +2 -0
  48. data/lib/action_view/helpers/tags/file_field.rb +2 -0
  49. data/lib/action_view/helpers/tags/grouped_collection_select.rb +3 -1
  50. data/lib/action_view/helpers/tags/hidden_field.rb +2 -0
  51. data/lib/action_view/helpers/tags/label.rb +2 -4
  52. data/lib/action_view/helpers/tags/month_field.rb +2 -0
  53. data/lib/action_view/helpers/tags/number_field.rb +2 -0
  54. data/lib/action_view/helpers/tags/password_field.rb +2 -0
  55. data/lib/action_view/helpers/tags/placeholderable.rb +2 -0
  56. data/lib/action_view/helpers/tags/radio_button.rb +3 -1
  57. data/lib/action_view/helpers/tags/range_field.rb +2 -0
  58. data/lib/action_view/helpers/tags/search_field.rb +2 -0
  59. data/lib/action_view/helpers/tags/select.rb +5 -3
  60. data/lib/action_view/helpers/tags/tel_field.rb +2 -0
  61. data/lib/action_view/helpers/tags/text_area.rb +3 -1
  62. data/lib/action_view/helpers/tags/text_field.rb +3 -1
  63. data/lib/action_view/helpers/tags/time_field.rb +2 -0
  64. data/lib/action_view/helpers/tags/time_select.rb +2 -0
  65. data/lib/action_view/helpers/tags/time_zone_select.rb +3 -1
  66. data/lib/action_view/helpers/tags/translator.rb +2 -0
  67. data/lib/action_view/helpers/tags/url_field.rb +2 -0
  68. data/lib/action_view/helpers/tags/week_field.rb +2 -0
  69. data/lib/action_view/helpers/text_helper.rb +4 -2
  70. data/lib/action_view/helpers/translation_helper.rb +5 -4
  71. data/lib/action_view/helpers/url_helper.rb +24 -5
  72. data/lib/action_view/layouts.rb +7 -5
  73. data/lib/action_view/log_subscriber.rb +5 -3
  74. data/lib/action_view/lookup_context.rb +4 -4
  75. data/lib/action_view/model_naming.rb +2 -0
  76. data/lib/action_view/path_set.rb +2 -0
  77. data/lib/action_view/railtie.rb +11 -2
  78. data/lib/action_view/record_identifier.rb +2 -0
  79. data/lib/action_view/renderer/abstract_renderer.rb +2 -0
  80. data/lib/action_view/renderer/partial_renderer.rb +13 -11
  81. data/lib/action_view/renderer/partial_renderer/collection_caching.rb +4 -2
  82. data/lib/action_view/renderer/renderer.rb +2 -0
  83. data/lib/action_view/renderer/streaming_template_renderer.rb +3 -1
  84. data/lib/action_view/renderer/template_renderer.rb +2 -0
  85. data/lib/action_view/rendering.rb +3 -5
  86. data/lib/action_view/routing_url_for.rb +2 -0
  87. data/lib/action_view/tasks/cache_digests.rake +2 -0
  88. data/lib/action_view/template.rb +6 -4
  89. data/lib/action_view/template/error.rb +2 -3
  90. data/lib/action_view/template/handlers.rb +3 -1
  91. data/lib/action_view/template/handlers/builder.rb +3 -4
  92. data/lib/action_view/template/handlers/erb.rb +5 -9
  93. data/lib/action_view/template/handlers/erb/erubi.rb +2 -0
  94. data/lib/action_view/template/handlers/html.rb +2 -0
  95. data/lib/action_view/template/handlers/raw.rb +2 -0
  96. data/lib/action_view/template/html.rb +3 -1
  97. data/lib/action_view/template/resolver.rb +7 -6
  98. data/lib/action_view/template/text.rb +3 -1
  99. data/lib/action_view/template/types.rb +3 -1
  100. data/lib/action_view/test_case.rb +21 -5
  101. data/lib/action_view/testing/resolvers.rb +3 -1
  102. data/lib/action_view/version.rb +2 -0
  103. data/lib/action_view/view_paths.rb +3 -3
  104. data/lib/assets/compiled/rails-ujs.js +3 -3
  105. metadata +14 -15
  106. data/lib/action_view/template/handlers/erb/deprecated_erubis.rb +0 -9
  107. data/lib/action_view/template/handlers/erb/erubis.rb +0 -81
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "action_view/helpers/tag_helper"
2
4
 
3
5
  module ActionView
4
- module Helpers
6
+ module Helpers #:nodoc:
5
7
  module JavaScriptHelper
6
8
  JS_ESCAPE_MAP = {
7
9
  '\\' => '\\\\',
@@ -13,8 +15,8 @@ module ActionView
13
15
  "'" => "\\'"
14
16
  }
15
17
 
16
- JS_ESCAPE_MAP["\342\200\250".force_encoding(Encoding::UTF_8).encode!] = "
"
17
- JS_ESCAPE_MAP["\342\200\251".force_encoding(Encoding::UTF_8).encode!] = "
"
18
+ JS_ESCAPE_MAP["\342\200\250".dup.force_encoding(Encoding::UTF_8).encode!] = "
"
19
+ JS_ESCAPE_MAP["\342\200\251".dup.force_encoding(Encoding::UTF_8).encode!] = "
"
18
20
 
19
21
  # Escapes carriage returns and single and double quotes for JavaScript segments.
20
22
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "active_support/core_ext/hash/keys"
2
4
  require "active_support/core_ext/string/output_safety"
3
5
  require "active_support/number_helper"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "active_support/core_ext/string/output_safety"
2
4
 
3
5
  module ActionView #:nodoc:
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionView
2
- module Helpers
4
+ module Helpers #:nodoc:
3
5
  module RecordTagHelper
4
6
  def div_for(*) # :nodoc:
5
7
  raise NoMethodError, "The `div_for` method has been removed from " \
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionView
2
- module Helpers
4
+ module Helpers #:nodoc:
3
5
  # = Action View Rendering
4
6
  #
5
7
  # Implements methods that allow rendering from a view context.
@@ -11,6 +13,7 @@ module ActionView
11
13
  # * <tt>:partial</tt> - See <tt>ActionView::PartialRenderer</tt>.
12
14
  # * <tt>:file</tt> - Renders an explicit template file (this used to be the old default), add :locals to pass in those.
13
15
  # * <tt>:inline</tt> - Renders an inline template similar to how it's done in the controller.
16
+ # * <tt>:text</tt> - Renders the text passed in out.
14
17
  # * <tt>:plain</tt> - Renders the text passed in out. Setting the content
15
18
  # type as <tt>text/plain</tt>.
16
19
  # * <tt>:html</tt> - Renders the HTML safe string passed in out, otherwise
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "active_support/core_ext/object/try"
2
4
  require "rails-html-sanitizer"
3
5
 
4
6
  module ActionView
5
7
  # = Action View Sanitize Helpers
6
- module Helpers
8
+ module Helpers #:nodoc:
7
9
  # The SanitizeHelper module provides a set of methods for scrubbing text of undesired HTML elements.
8
10
  # These helper methods extend Action View making them callable within your template files.
9
11
  module SanitizeHelper
@@ -1,4 +1,4 @@
1
- # frozen-string-literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  require "active_support/core_ext/string/output_safety"
4
4
  require "set"
@@ -166,7 +166,7 @@ module ActionView
166
166
  # This may come in handy when using jQuery's HTML5-aware <tt>.data()</tt>
167
167
  # from 1.4.3.
168
168
  #
169
- # tag.div data: { city_state: %w( Chigaco IL ) }
169
+ # tag.div data: { city_state: %w( Chicago IL ) }
170
170
  # # => <div data-city-state="[&quot;Chicago&quot;,&quot;IL&quot;]"></div>
171
171
  #
172
172
  # The generated attributes are escaped by default. This can be disabled using
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionView
2
- module Helpers
4
+ module Helpers #:nodoc:
3
5
  module Tags #:nodoc:
4
6
  extend ActiveSupport::Autoload
5
7
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionView
2
4
  module Helpers
3
5
  module Tags # :nodoc:
@@ -33,7 +35,7 @@ module ActionView
33
35
 
34
36
  private
35
37
 
36
- def value(object)
38
+ def value
37
39
  if @allow_method_names_outside_object
38
40
  object.public_send @method_name if object && object.respond_to?(@method_name)
39
41
  else
@@ -41,19 +43,19 @@ module ActionView
41
43
  end
42
44
  end
43
45
 
44
- def value_before_type_cast(object)
46
+ def value_before_type_cast
45
47
  unless object.nil?
46
48
  method_before_type_cast = @method_name + "_before_type_cast"
47
49
 
48
- if value_came_from_user?(object) && object.respond_to?(method_before_type_cast)
50
+ if value_came_from_user? && object.respond_to?(method_before_type_cast)
49
51
  object.public_send(method_before_type_cast)
50
52
  else
51
- value(object)
53
+ value
52
54
  end
53
55
  end
54
56
  end
55
57
 
56
- def value_came_from_user?(object)
58
+ def value_came_from_user?
57
59
  method_name = "#{@method_name}_came_from_user?"
58
60
  !object.respond_to?(method_name) || object.public_send(method_name)
59
61
  end
@@ -95,7 +97,7 @@ module ActionView
95
97
  index = name_and_id_index(options)
96
98
  options["name"] = options.fetch("name") { tag_name(options["multiple"], index) }
97
99
 
98
- unless skip_default_ids?
100
+ if generate_ids?
99
101
  options["id"] = options.fetch("id") { tag_id(index) }
100
102
  if namespace = options.delete("namespace")
101
103
  options["id"] = options["id"] ? "#{namespace}_#{options['id']}" : namespace
@@ -148,8 +150,8 @@ module ActionView
148
150
  options[:include_blank] ||= true unless options[:prompt]
149
151
  end
150
152
 
151
- value = options.fetch(:selected) { value(object) }
152
- select = content_tag("select", add_options(option_tags, options, value), html_options.except!("skip_default_ids", "allow_method_names_outside_object"))
153
+ value = options.fetch(:selected) { value() }
154
+ select = content_tag("select", add_options(option_tags, options, value), html_options)
153
155
 
154
156
  if html_options["multiple"] && options.fetch(:include_hidden, true)
155
157
  tag("input", disabled: html_options["disabled"], name: html_options["name"], type: "hidden", value: "") + select
@@ -181,8 +183,8 @@ module ActionView
181
183
  end
182
184
  end
183
185
 
184
- def skip_default_ids?
185
- @skip_default_ids
186
+ def generate_ids?
187
+ !@skip_default_ids
186
188
  end
187
189
  end
188
190
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "action_view/helpers/tags/checkable"
2
4
 
3
5
  module ActionView
@@ -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)
@@ -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,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "action_view/helpers/tags/collection_helpers"
2
4
 
3
5
  module ActionView
@@ -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
  require "action_view/helpers/tags/collection_helpers"
2
4
 
3
5
  module ActionView
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionView
2
4
  module Helpers
3
5
  module Tags # :nodoc:
@@ -13,7 +15,7 @@ module ActionView
13
15
 
14
16
  def render
15
17
  option_tags_options = {
16
- selected: @options.fetch(:selected) { value(@object) },
18
+ selected: @options.fetch(:selected) { value },
17
19
  disabled: @options[:disabled]
18
20
  }
19
21
 
@@ -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,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "active_support/core_ext/time/calculations"
2
4
 
3
5
  module ActionView
@@ -27,7 +29,7 @@ module ActionView
27
29
  end
28
30
 
29
31
  def datetime_selector(options, html_options)
30
- datetime = options.fetch(:selected) { value(object) || default_datetime(options) }
32
+ datetime = options.fetch(:selected) { value || default_datetime(options) }
31
33
  @auto_index ||= nil
32
34
 
33
35
  options = options.dup
@@ -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
@@ -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,7 +17,7 @@ module ActionView
15
17
 
16
18
  def render
17
19
  option_tags_options = {
18
- selected: @options.fetch(:selected) { value(@object) },
20
+ selected: @options.fetch(:selected) { value },
19
21
  disabled: @options[:disabled]
20
22
  }
21
23
 
@@ -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:
@@ -73,10 +75,6 @@ module ActionView
73
75
  def render_component(builder)
74
76
  builder.translation
75
77
  end
76
-
77
- def skip_default_ids?
78
- false # The id is used as the `for` attribute.
79
- end
80
78
  end
81
79
  end
82
80
  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,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
  require "action_view/helpers/tags/checkable"
2
4
 
3
5
  module ActionView
@@ -15,7 +17,7 @@ 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
@@ -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:
@@ -6,14 +8,14 @@ module ActionView
6
8
  @choices = block_given? ? template_object.capture { yield || "" } : choices
7
9
  @choices = @choices.to_a if @choices.is_a?(Range)
8
10
 
9
- @html_options = html_options
11
+ @html_options = html_options.except(:skip_default_ids, :allow_method_names_outside_object)
10
12
 
11
13
  super(object_name, method_name, template_object, options)
12
14
  end
13
15
 
14
16
  def render
15
17
  option_tags_options = {
16
- selected: @options.fetch(:selected) { value(@object) },
18
+ selected: @options.fetch(:selected) { value },
17
19
  disabled: @options[:disabled]
18
20
  }
19
21
 
@@ -33,7 +35,7 @@ module ActionView
33
35
  # [nil, []]
34
36
  # { nil => [] }
35
37
  def grouped_choices?
36
- !@choices.empty? && @choices.first.respond_to?(:last) && Array === @choices.first.last
38
+ !@choices.blank? && @choices.first.respond_to?(:last) && Array === @choices.first.last
37
39
  end
38
40
  end
39
41
  end