actionview 6.0.0 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +169 -162
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +1 -1
  5. data/lib/action_view/base.rb +21 -52
  6. data/lib/action_view/cache_expiry.rb +1 -3
  7. data/lib/action_view/context.rb +0 -1
  8. data/lib/action_view/dependency_tracker.rb +10 -4
  9. data/lib/action_view/digestor.rb +3 -2
  10. data/lib/action_view/flows.rb +0 -1
  11. data/lib/action_view/gem_version.rb +1 -1
  12. data/lib/action_view/helpers/active_model_helper.rb +0 -1
  13. data/lib/action_view/helpers/asset_tag_helper.rb +41 -16
  14. data/lib/action_view/helpers/asset_url_helper.rb +6 -4
  15. data/lib/action_view/helpers/atom_feed_helper.rb +2 -1
  16. data/lib/action_view/helpers/cache_helper.rb +11 -18
  17. data/lib/action_view/helpers/date_helper.rb +5 -6
  18. data/lib/action_view/helpers/form_helper.rb +61 -19
  19. data/lib/action_view/helpers/form_options_helper.rb +7 -16
  20. data/lib/action_view/helpers/form_tag_helper.rb +9 -7
  21. data/lib/action_view/helpers/javascript_helper.rb +7 -5
  22. data/lib/action_view/helpers/number_helper.rb +9 -8
  23. data/lib/action_view/helpers/rendering_helper.rb +11 -3
  24. data/lib/action_view/helpers/sanitize_helper.rb +2 -2
  25. data/lib/action_view/helpers/tag_helper.rb +94 -19
  26. data/lib/action_view/helpers/tags/base.rb +9 -6
  27. data/lib/action_view/helpers/tags/check_box.rb +0 -1
  28. data/lib/action_view/helpers/tags/collection_check_boxes.rb +0 -1
  29. data/lib/action_view/helpers/tags/collection_helpers.rb +0 -1
  30. data/lib/action_view/helpers/tags/collection_radio_buttons.rb +0 -1
  31. data/lib/action_view/helpers/tags/color_field.rb +0 -1
  32. data/lib/action_view/helpers/tags/date_field.rb +1 -2
  33. data/lib/action_view/helpers/tags/date_select.rb +2 -3
  34. data/lib/action_view/helpers/tags/datetime_field.rb +0 -1
  35. data/lib/action_view/helpers/tags/datetime_local_field.rb +1 -2
  36. data/lib/action_view/helpers/tags/label.rb +4 -1
  37. data/lib/action_view/helpers/tags/month_field.rb +1 -2
  38. data/lib/action_view/helpers/tags/radio_button.rb +0 -1
  39. data/lib/action_view/helpers/tags/select.rb +1 -2
  40. data/lib/action_view/helpers/tags/text_field.rb +0 -1
  41. data/lib/action_view/helpers/tags/time_field.rb +1 -2
  42. data/lib/action_view/helpers/tags/week_field.rb +1 -2
  43. data/lib/action_view/helpers/text_helper.rb +1 -2
  44. data/lib/action_view/helpers/translation_helper.rb +98 -53
  45. data/lib/action_view/helpers/url_helper.rb +107 -13
  46. data/lib/action_view/layouts.rb +3 -5
  47. data/lib/action_view/log_subscriber.rb +26 -11
  48. data/lib/action_view/lookup_context.rb +7 -21
  49. data/lib/action_view/path_set.rb +0 -4
  50. data/lib/action_view/railtie.rb +35 -46
  51. data/lib/action_view/record_identifier.rb +0 -1
  52. data/lib/action_view/renderer/abstract_renderer.rb +92 -14
  53. data/lib/action_view/renderer/collection_renderer.rb +192 -0
  54. data/lib/action_view/renderer/object_renderer.rb +34 -0
  55. data/lib/action_view/renderer/partial_renderer/collection_caching.rb +25 -26
  56. data/lib/action_view/renderer/partial_renderer.rb +20 -283
  57. data/lib/action_view/renderer/renderer.rb +44 -1
  58. data/lib/action_view/renderer/streaming_template_renderer.rb +5 -3
  59. data/lib/action_view/renderer/template_renderer.rb +16 -14
  60. data/lib/action_view/rendering.rb +3 -2
  61. data/lib/action_view/routing_url_for.rb +1 -1
  62. data/lib/action_view/template/error.rb +9 -14
  63. data/lib/action_view/template/handlers/erb/erubi.rb +9 -7
  64. data/lib/action_view/template/handlers/erb.rb +10 -15
  65. data/lib/action_view/template/handlers.rb +0 -26
  66. data/lib/action_view/template/html.rb +1 -11
  67. data/lib/action_view/template/raw_file.rb +0 -3
  68. data/lib/action_view/template/renderable.rb +24 -0
  69. data/lib/action_view/template/resolver.rb +83 -45
  70. data/lib/action_view/template/text.rb +0 -3
  71. data/lib/action_view/template.rb +9 -50
  72. data/lib/action_view/test_case.rb +20 -28
  73. data/lib/action_view/testing/resolvers.rb +10 -32
  74. data/lib/action_view/unbound_template.rb +4 -5
  75. data/lib/action_view/view_paths.rb +34 -37
  76. data/lib/action_view.rb +5 -1
  77. data/lib/assets/compiled/rails-ujs.js +3 -3
  78. metadata +17 -11
@@ -16,11 +16,12 @@ module ActionView
16
16
  attr_accessor :request, :response, :params
17
17
 
18
18
  class << self
19
- attr_writer :controller_path
19
+ # Overrides AbstractController::Base#controller_path
20
+ attr_accessor :controller_path
20
21
  end
21
22
 
22
23
  def controller_path=(path)
23
- self.class.controller_path = (path)
24
+ self.class.controller_path = path
24
25
  end
25
26
 
26
27
  def initialize
@@ -73,10 +74,11 @@ module ActionView
73
74
  def helper_method(*methods)
74
75
  # Almost a duplicate from ActionController::Helpers
75
76
  methods.flatten.each do |method|
76
- _helpers.module_eval <<-end_eval, __FILE__, __LINE__ + 1
77
+ _helpers_for_modification.module_eval <<-end_eval, __FILE__, __LINE__ + 1
77
78
  def #{method}(*args, &block) # def current_user(*args, &block)
78
- _test_case.send(%(#{method}), *args, &block) # _test_case.send(%(current_user), *args, &block)
79
+ _test_case.send(:'#{method}', *args, &block) # _test_case.send(:'current_user', *args, &block)
79
80
  end # end
81
+ ruby2_keywords(:'#{method}') if respond_to?(:ruby2_keywords, true)
80
82
  end_eval
81
83
  end
82
84
  end
@@ -93,7 +95,6 @@ module ActionView
93
95
  end
94
96
 
95
97
  private
96
-
97
98
  def include_helper_modules!
98
99
  helper(helper_class) if helper_class
99
100
  include _helpers
@@ -101,7 +102,8 @@ module ActionView
101
102
  end
102
103
 
103
104
  def setup_with_controller
104
- @controller = ActionView::TestCase::TestController.new
105
+ controller_class = Class.new(ActionView::TestCase::TestController)
106
+ @controller = controller_class.new
105
107
  @request = @controller.request
106
108
  @view_flow = ActionView::OutputFlow.new
107
109
  # empty string ensures buffer has UTF-8 encoding as
@@ -109,8 +111,8 @@ module ActionView
109
111
  @output_buffer = ActiveSupport::SafeBuffer.new ""
110
112
  @rendered = +""
111
113
 
112
- make_test_case_available_to_view!
113
- say_no_to_protect_against_forgery!
114
+ test_case_instance = self
115
+ controller_class.define_method(:_test_case) { test_case_instance }
114
116
  end
115
117
 
116
118
  def config
@@ -160,34 +162,24 @@ module ActionView
160
162
  included do
161
163
  setup :setup_with_controller
162
164
  ActiveSupport.run_load_hooks(:action_view_test_case, self)
163
- end
164
-
165
- private
166
-
167
- # Need to experiment if this priority is the best one: rendered => output_buffer
168
- def document_root_element
169
- Nokogiri::HTML::Document.parse(@rendered.blank? ? @output_buffer : @rendered).root
170
- end
171
165
 
172
- def say_no_to_protect_against_forgery!
173
- _helpers.module_eval do
174
- silence_redefinition_of_method :protect_against_forgery?
166
+ helper do
175
167
  def protect_against_forgery?
176
168
  false
177
169
  end
178
- end
179
- end
180
170
 
181
- def make_test_case_available_to_view!
182
- test_case_instance = self
183
- _helpers.module_eval do
184
- unless private_method_defined?(:_test_case)
185
- define_method(:_test_case) { test_case_instance }
186
- private :_test_case
171
+ def _test_case
172
+ controller._test_case
187
173
  end
188
174
  end
189
175
  end
190
176
 
177
+ private
178
+ # Need to experiment if this priority is the best one: rendered => output_buffer
179
+ def document_root_element
180
+ Nokogiri::HTML::Document.parse(@rendered.blank? ? @output_buffer : @rendered).root
181
+ end
182
+
191
183
  module Locals
192
184
  attr_accessor :rendered_views
193
185
 
@@ -284,7 +276,7 @@ module ActionView
284
276
 
285
277
  def respond_to_missing?(name, include_private = false)
286
278
  begin
287
- routes = @controller.respond_to?(:_routes) && @controller._routes
279
+ routes = defined?(@controller) && @controller.respond_to?(:_routes) && @controller._routes
288
280
  rescue
289
281
  # Don't call routes, if there is an error on _routes call
290
282
  end
@@ -8,12 +8,8 @@ module ActionView #:nodoc:
8
8
  # useful for testing extensions that have no way of knowing what the file
9
9
  # system will look like at runtime.
10
10
  class FixtureResolver < OptimizedFileSystemResolver
11
- def initialize(hash = {}, pattern = nil)
11
+ def initialize(hash = {})
12
12
  super("")
13
- if pattern
14
- ActiveSupport::Deprecation.warn "Specifying a custom path for #{self.class} is deprecated. Implement a custom Resolver subclass instead."
15
- @pattern = pattern
16
- end
17
13
  @hash = hash
18
14
  @path = ""
19
15
  end
@@ -27,35 +23,17 @@ module ActionView #:nodoc:
27
23
  end
28
24
 
29
25
  private
30
-
31
- def query(path, exts, _, locals, cache:)
32
- regex = build_regex(path, exts)
33
-
34
- @hash.select do |_path, _|
35
- ("/" + _path).match?(regex)
36
- end.map do |_path, source|
37
- handler, format, variant = extract_handler_and_format_and_variant(_path)
38
-
39
- Template.new(source, _path, handler,
40
- virtual_path: path.virtual,
41
- format: format,
42
- variant: variant,
43
- locals: locals
44
- )
45
- end.sort_by do |t|
46
- match = ("/" + t.identifier).match(regex)
47
- EXTENSIONS.keys.reverse.map do |ext|
48
- if ext == :variants && exts[ext] == :any
49
- match[ext].nil? ? 0 : 1
50
- elsif match[ext].nil?
51
- exts[ext].length
52
- else
53
- found = match[ext].to_sym
54
- exts[ext].index(found)
55
- end
56
- end
26
+ def find_candidate_template_paths(path)
27
+ @hash.keys.select do |fixture|
28
+ fixture.start_with?(path.virtual)
29
+ end.map do |fixture|
30
+ "/#{fixture}"
57
31
  end
58
32
  end
33
+
34
+ def source_for_template(template)
35
+ @hash[template[1..template.size]]
36
+ end
59
37
  end
60
38
 
61
39
  class NullResolver < PathResolver
@@ -4,9 +4,9 @@ require "concurrent/map"
4
4
 
5
5
  module ActionView
6
6
  class UnboundTemplate
7
- def initialize(source, identifer, handler, options)
7
+ def initialize(source, identifier, handler, options)
8
8
  @source = source
9
- @identifer = identifer
9
+ @identifier = identifier
10
10
  @handler = handler
11
11
  @options = options
12
12
 
@@ -18,14 +18,13 @@ module ActionView
18
18
  end
19
19
 
20
20
  private
21
-
22
21
  def build_template(locals)
23
22
  options = @options.merge(locals: locals)
24
23
  Template.new(
25
24
  @source,
26
- @identifer,
25
+ @identifier,
27
26
  @handler,
28
- options
27
+ **options
29
28
  )
30
29
  end
31
30
  end
@@ -28,8 +28,41 @@ module ActionView
28
28
  end
29
29
  end
30
30
 
31
- private
31
+ # Append a path to the list of view paths for this controller.
32
+ #
33
+ # ==== Parameters
34
+ # * <tt>path</tt> - If a String is provided, it gets converted into
35
+ # the default view path. You may also provide a custom view path
36
+ # (see ActionView::PathSet for more information)
37
+ def append_view_path(path)
38
+ self._view_paths = view_paths + Array(path)
39
+ end
40
+
41
+ # Prepend a path to the list of view paths for this controller.
42
+ #
43
+ # ==== Parameters
44
+ # * <tt>path</tt> - If a String is provided, it gets converted into
45
+ # the default view path. You may also provide a custom view path
46
+ # (see ActionView::PathSet for more information)
47
+ def prepend_view_path(path)
48
+ self._view_paths = ActionView::PathSet.new(Array(path) + view_paths)
49
+ end
50
+
51
+ # A list of all of the default view paths for this controller.
52
+ def view_paths
53
+ _view_paths
54
+ end
55
+
56
+ # Set the view paths.
57
+ #
58
+ # ==== Parameters
59
+ # * <tt>paths</tt> - If a PathSet is provided, use that;
60
+ # otherwise, process the parameter into a PathSet.
61
+ def view_paths=(paths)
62
+ self._view_paths = ActionView::PathSet.new(Array(paths))
63
+ end
32
64
 
65
+ private
33
66
  # Override this method in your controller if you want to change paths prefixes for finding views.
34
67
  # Prefixes defined here will still be added to parents' <tt>._prefixes</tt>.
35
68
  def local_prefixes
@@ -89,41 +122,5 @@ module ActionView
89
122
  def prepend_view_path(path)
90
123
  lookup_context.view_paths.unshift(*path)
91
124
  end
92
-
93
- module ClassMethods
94
- # Append a path to the list of view paths for this controller.
95
- #
96
- # ==== Parameters
97
- # * <tt>path</tt> - If a String is provided, it gets converted into
98
- # the default view path. You may also provide a custom view path
99
- # (see ActionView::PathSet for more information)
100
- def append_view_path(path)
101
- self._view_paths = view_paths + Array(path)
102
- end
103
-
104
- # Prepend a path to the list of view paths for this controller.
105
- #
106
- # ==== Parameters
107
- # * <tt>path</tt> - If a String is provided, it gets converted into
108
- # the default view path. You may also provide a custom view path
109
- # (see ActionView::PathSet for more information)
110
- def prepend_view_path(path)
111
- self._view_paths = ActionView::PathSet.new(Array(path) + view_paths)
112
- end
113
-
114
- # A list of all of the default view paths for this controller.
115
- def view_paths
116
- _view_paths
117
- end
118
-
119
- # Set the view paths.
120
- #
121
- # ==== Parameters
122
- # * <tt>paths</tt> - If a PathSet is provided, use that;
123
- # otherwise, process the parameter into a PathSet.
124
- def view_paths=(paths)
125
- self._view_paths = ActionView::PathSet.new(Array(paths))
126
- end
127
- end
128
125
  end
129
126
  end
data/lib/action_view.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # Copyright (c) 2004-2019 David Heinemeier Hansson
4
+ # Copyright (c) 2004-2020 David Heinemeier Hansson
5
5
  #
6
6
  # Permission is hereby granted, free of charge, to any person obtaining
7
7
  # a copy of this software and associated documentation files (the
@@ -51,6 +51,8 @@ module ActionView
51
51
  autoload :Renderer
52
52
  autoload :AbstractRenderer
53
53
  autoload :PartialRenderer
54
+ autoload :CollectionRenderer
55
+ autoload :ObjectRenderer
54
56
  autoload :TemplateRenderer
55
57
  autoload :StreamingTemplateRenderer
56
58
  end
@@ -58,6 +60,7 @@ module ActionView
58
60
  autoload_at "action_view/template/resolver" do
59
61
  autoload :Resolver
60
62
  autoload :PathResolver
63
+ autoload :FileSystemResolver
61
64
  autoload :OptimizedFileSystemResolver
62
65
  autoload :FallbackFileSystemResolver
63
66
  end
@@ -77,6 +80,7 @@ module ActionView
77
80
  autoload :ActionViewError
78
81
  autoload :EncodingError
79
82
  autoload :TemplateError
83
+ autoload :SyntaxErrorInTemplate
80
84
  autoload :WrongEncodingError
81
85
  end
82
86
  end
@@ -2,7 +2,7 @@
2
2
  Unobtrusive JavaScript
3
3
  https://github.com/rails/rails/blob/master/actionview/app/assets/javascripts
4
4
  Released under the MIT license
5
- */
5
+ */;
6
6
 
7
7
  (function() {
8
8
  var context = this;
@@ -247,8 +247,8 @@ Released under the MIT license
247
247
  }
248
248
  if (!options.crossDomain) {
249
249
  xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
250
+ CSRFProtection(xhr);
250
251
  }
251
- CSRFProtection(xhr);
252
252
  xhr.withCredentials = !!options.withCredentials;
253
253
  xhr.onreadystatechange = function() {
254
254
  if (xhr.readyState === XMLHttpRequest.DONE) {
@@ -320,7 +320,7 @@ Released under the MIT license
320
320
  if (!input.name || input.disabled) {
321
321
  return;
322
322
  }
323
- if (input.closest('fieldset[disabled]')) {
323
+ if (matches(input, 'fieldset[disabled] *')) {
324
324
  return;
325
325
  }
326
326
  if (matches(input, 'select')) {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionview
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0
4
+ version: 6.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-16 00:00:00.000000000 Z
11
+ date: 2020-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 6.0.0
19
+ version: 6.1.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 6.0.0
26
+ version: 6.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: builder
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -92,28 +92,28 @@ dependencies:
92
92
  requirements:
93
93
  - - '='
94
94
  - !ruby/object:Gem::Version
95
- version: 6.0.0
95
+ version: 6.1.0
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - '='
101
101
  - !ruby/object:Gem::Version
102
- version: 6.0.0
102
+ version: 6.1.0
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: activemodel
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - '='
108
108
  - !ruby/object:Gem::Version
109
- version: 6.0.0
109
+ version: 6.1.0
110
110
  type: :development
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - '='
115
115
  - !ruby/object:Gem::Version
116
- version: 6.0.0
116
+ version: 6.1.0
117
117
  description: Simple, battle-tested conventions and helpers for building web pages.
118
118
  email: david@loudthinking.com
119
119
  executables: []
@@ -201,6 +201,8 @@ files:
201
201
  - lib/action_view/railtie.rb
202
202
  - lib/action_view/record_identifier.rb
203
203
  - lib/action_view/renderer/abstract_renderer.rb
204
+ - lib/action_view/renderer/collection_renderer.rb
205
+ - lib/action_view/renderer/object_renderer.rb
204
206
  - lib/action_view/renderer/partial_renderer.rb
205
207
  - lib/action_view/renderer/partial_renderer/collection_caching.rb
206
208
  - lib/action_view/renderer/renderer.rb
@@ -220,6 +222,7 @@ files:
220
222
  - lib/action_view/template/html.rb
221
223
  - lib/action_view/template/inline.rb
222
224
  - lib/action_view/template/raw_file.rb
225
+ - lib/action_view/template/renderable.rb
223
226
  - lib/action_view/template/resolver.rb
224
227
  - lib/action_view/template/sources.rb
225
228
  - lib/action_view/template/sources/file.rb
@@ -235,8 +238,11 @@ homepage: https://rubyonrails.org
235
238
  licenses:
236
239
  - MIT
237
240
  metadata:
238
- source_code_uri: https://github.com/rails/rails/tree/v6.0.0/actionview
239
- changelog_uri: https://github.com/rails/rails/blob/v6.0.0/actionview/CHANGELOG.md
241
+ bug_tracker_uri: https://github.com/rails/rails/issues
242
+ changelog_uri: https://github.com/rails/rails/blob/v6.1.0/actionview/CHANGELOG.md
243
+ documentation_uri: https://api.rubyonrails.org/v6.1.0/
244
+ mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
245
+ source_code_uri: https://github.com/rails/rails/tree/v6.1.0/actionview
240
246
  post_install_message:
241
247
  rdoc_options: []
242
248
  require_paths:
@@ -253,7 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
253
259
  version: '0'
254
260
  requirements:
255
261
  - none
256
- rubygems_version: 3.0.1
262
+ rubygems_version: 3.1.4
257
263
  signing_key:
258
264
  specification_version: 4
259
265
  summary: Rendering framework putting the V in MVC (part of Rails).