actionview 7.1.5.1 → 7.2.2.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +54 -432
- data/lib/action_view/base.rb +20 -2
- data/lib/action_view/cache_expiry.rb +9 -3
- data/lib/action_view/dependency_tracker/{ripper_tracker.rb → ruby_tracker.rb} +4 -3
- data/lib/action_view/dependency_tracker.rb +1 -1
- data/lib/action_view/gem_version.rb +3 -3
- data/lib/action_view/helpers/asset_tag_helper.rb +15 -3
- data/lib/action_view/helpers/csrf_helper.rb +1 -1
- data/lib/action_view/helpers/form_helper.rb +197 -192
- data/lib/action_view/helpers/form_tag_helper.rb +80 -47
- data/lib/action_view/helpers/output_safety_helper.rb +4 -4
- data/lib/action_view/helpers/tag_helper.rb +208 -18
- data/lib/action_view/helpers/text_helper.rb +1 -1
- data/lib/action_view/helpers/url_helper.rb +3 -77
- data/lib/action_view/layouts.rb +2 -4
- data/lib/action_view/log_subscriber.rb +8 -4
- data/lib/action_view/railtie.rb +0 -1
- data/lib/action_view/render_parser/prism_render_parser.rb +127 -0
- data/lib/action_view/{ripper_ast_parser.rb → render_parser/ripper_render_parser.rb} +152 -9
- data/lib/action_view/render_parser.rb +21 -169
- data/lib/action_view/renderer/abstract_renderer.rb +1 -1
- data/lib/action_view/renderer/renderer.rb +32 -38
- data/lib/action_view/rendering.rb +4 -4
- data/lib/action_view/template/renderable.rb +7 -1
- data/lib/action_view/template/resolver.rb +0 -2
- data/lib/action_view/template.rb +36 -8
- data/lib/action_view/test_case.rb +7 -9
- metadata +16 -18
|
@@ -27,10 +27,10 @@ module ActionView
|
|
|
27
27
|
extend ActiveSupport::Concern
|
|
28
28
|
include ActionView::ViewPaths
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
attr_internal_reader :rendered_format
|
|
31
31
|
|
|
32
32
|
def initialize
|
|
33
|
-
@
|
|
33
|
+
@_rendered_format = nil
|
|
34
34
|
super
|
|
35
35
|
end
|
|
36
36
|
|
|
@@ -136,7 +136,7 @@ module ActionView
|
|
|
136
136
|
end
|
|
137
137
|
|
|
138
138
|
rendered_format = rendered_template.format || lookup_context.formats.first
|
|
139
|
-
@
|
|
139
|
+
@_rendered_format = Template::Types[rendered_format]
|
|
140
140
|
|
|
141
141
|
rendered_template.body
|
|
142
142
|
end
|
|
@@ -179,7 +179,7 @@ module ActionView
|
|
|
179
179
|
options[:partial] = action_name
|
|
180
180
|
end
|
|
181
181
|
|
|
182
|
-
if
|
|
182
|
+
if !options.keys.intersect?([:partial, :file, :template])
|
|
183
183
|
options[:prefixes] ||= _prefixes
|
|
184
184
|
end
|
|
185
185
|
|
|
@@ -14,10 +14,16 @@ module ActionView
|
|
|
14
14
|
|
|
15
15
|
def render(context, *args)
|
|
16
16
|
@renderable.render_in(context)
|
|
17
|
+
rescue NoMethodError
|
|
18
|
+
if !@renderable.respond_to?(:render_in)
|
|
19
|
+
raise ArgumentError, "'#{@renderable.inspect}' is not a renderable object. It must implement #render_in."
|
|
20
|
+
else
|
|
21
|
+
raise
|
|
22
|
+
end
|
|
17
23
|
end
|
|
18
24
|
|
|
19
25
|
def format
|
|
20
|
-
@renderable.format
|
|
26
|
+
@renderable.try(:format)
|
|
21
27
|
end
|
|
22
28
|
end
|
|
23
29
|
end
|
data/lib/action_view/template.rb
CHANGED
|
@@ -148,6 +148,20 @@ module ActionView
|
|
|
148
148
|
# <p><%= alert %></p>
|
|
149
149
|
# <% end %>
|
|
150
150
|
#
|
|
151
|
+
# By default, templates will accept any <tt>locals</tt> as keyword arguments
|
|
152
|
+
# and make them available to <tt>local_assigns</tt>. To restrict what
|
|
153
|
+
# <tt>local_assigns</tt> a template will accept, add a <tt>locals:</tt> magic comment:
|
|
154
|
+
#
|
|
155
|
+
# <%# locals: (headline:, alerts: []) %>
|
|
156
|
+
#
|
|
157
|
+
# <h1><%= headline %></h1>
|
|
158
|
+
#
|
|
159
|
+
# <% alerts.each do |alert| %>
|
|
160
|
+
# <p><%= alert %></p>
|
|
161
|
+
# <% end %>
|
|
162
|
+
#
|
|
163
|
+
# Read more about strict locals in {Action View Overview}[https://guides.rubyonrails.org/action_view_overview.html#strict-locals]
|
|
164
|
+
# in the guides.
|
|
151
165
|
|
|
152
166
|
eager_autoload do
|
|
153
167
|
autoload :Error
|
|
@@ -216,11 +230,21 @@ module ActionView
|
|
|
216
230
|
end
|
|
217
231
|
|
|
218
232
|
def spot(location) # :nodoc:
|
|
219
|
-
ast = RubyVM::AbstractSyntaxTree.parse(compiled_source, keep_script_lines: true)
|
|
220
233
|
node_id = RubyVM::AbstractSyntaxTree.node_id_for_backtrace_location(location)
|
|
221
|
-
|
|
234
|
+
found =
|
|
235
|
+
if RubyVM::InstructionSequence.compile("").to_a[4][:parser] == :prism
|
|
236
|
+
require "prism"
|
|
222
237
|
|
|
223
|
-
|
|
238
|
+
if Prism::VERSION >= "1.0.0"
|
|
239
|
+
result = Prism.parse(compiled_source).value
|
|
240
|
+
result.breadth_first_search { |node| node.node_id == node_id }
|
|
241
|
+
end
|
|
242
|
+
else
|
|
243
|
+
node = RubyVM::AbstractSyntaxTree.parse(compiled_source, keep_script_lines: true)
|
|
244
|
+
find_node_by_id(node, node_id)
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
ErrorHighlight.spot(found) if found
|
|
224
248
|
end
|
|
225
249
|
|
|
226
250
|
# Translate an error location returned by ErrorHighlight to the correct
|
|
@@ -425,9 +449,9 @@ module ActionView
|
|
|
425
449
|
method_arguments =
|
|
426
450
|
if set_strict_locals
|
|
427
451
|
if set_strict_locals.include?("&")
|
|
428
|
-
"output_buffer, #{set_strict_locals}"
|
|
452
|
+
"local_assigns, output_buffer, #{set_strict_locals}"
|
|
429
453
|
else
|
|
430
|
-
"output_buffer, #{set_strict_locals}, &_"
|
|
454
|
+
"local_assigns, output_buffer, #{set_strict_locals}, &_"
|
|
431
455
|
end
|
|
432
456
|
else
|
|
433
457
|
"local_assigns, output_buffer, &_"
|
|
@@ -486,11 +510,12 @@ module ActionView
|
|
|
486
510
|
|
|
487
511
|
return unless strict_locals?
|
|
488
512
|
|
|
489
|
-
parameters = mod.instance_method(method_name).parameters
|
|
513
|
+
parameters = mod.instance_method(method_name).parameters
|
|
514
|
+
parameters -= [[:req, :local_assigns], [:req, :output_buffer]]
|
|
515
|
+
|
|
490
516
|
# Check compiled method parameters to ensure that only kwargs
|
|
491
517
|
# were provided as strict locals, preventing `locals: (foo, *foo)` etc
|
|
492
518
|
# and allowing `locals: (foo:)`.
|
|
493
|
-
|
|
494
519
|
non_kwarg_parameters = parameters.select do |parameter|
|
|
495
520
|
![:keyreq, :key, :keyrest, :nokey].include?(parameter[0])
|
|
496
521
|
end
|
|
@@ -531,12 +556,15 @@ module ActionView
|
|
|
531
556
|
end
|
|
532
557
|
end
|
|
533
558
|
|
|
559
|
+
RUBY_RESERVED_KEYWORDS = ::ActiveSupport::Delegation::RUBY_RESERVED_KEYWORDS
|
|
560
|
+
private_constant :RUBY_RESERVED_KEYWORDS
|
|
561
|
+
|
|
534
562
|
def locals_code
|
|
535
563
|
return "" if strict_locals?
|
|
536
564
|
|
|
537
565
|
# Only locals with valid variable names get set directly. Others will
|
|
538
566
|
# still be available in local_assigns.
|
|
539
|
-
locals = @locals -
|
|
567
|
+
locals = @locals - RUBY_RESERVED_KEYWORDS
|
|
540
568
|
|
|
541
569
|
locals = locals.grep(/\A(?![A-Z0-9])(?:[[:alnum:]_]|[^\0-\177])+\z/)
|
|
542
570
|
|
|
@@ -171,10 +171,9 @@ module ActionView
|
|
|
171
171
|
# Almost a duplicate from ActionController::Helpers
|
|
172
172
|
methods.flatten.each do |method|
|
|
173
173
|
_helpers_for_modification.module_eval <<~end_eval, __FILE__, __LINE__ + 1
|
|
174
|
-
def #{method}(
|
|
175
|
-
_test_case.send(:'#{method}',
|
|
176
|
-
end
|
|
177
|
-
ruby2_keywords(:'#{method}')
|
|
174
|
+
def #{method}(...) # def current_user(...)
|
|
175
|
+
_test_case.send(:'#{method}', ...) # _test_case.send(:'current_user', ...)
|
|
176
|
+
end # end
|
|
178
177
|
end_eval
|
|
179
178
|
end
|
|
180
179
|
end
|
|
@@ -202,7 +201,7 @@ module ActionView
|
|
|
202
201
|
|
|
203
202
|
setup :setup_with_controller
|
|
204
203
|
|
|
205
|
-
register_parser :html, -> rendered { Rails::Dom::Testing.
|
|
204
|
+
register_parser :html, -> rendered { Rails::Dom::Testing.html_document_fragment.parse(rendered) }
|
|
206
205
|
register_parser :json, -> rendered { JSON.parse(rendered, object_class: ActiveSupport::HashWithIndifferentAccess) }
|
|
207
206
|
|
|
208
207
|
ActiveSupport.run_load_hooks(:action_view_test_case, self)
|
|
@@ -416,7 +415,7 @@ module ActionView
|
|
|
416
415
|
end]
|
|
417
416
|
end
|
|
418
417
|
|
|
419
|
-
def method_missing(selector,
|
|
418
|
+
def method_missing(selector, ...)
|
|
420
419
|
begin
|
|
421
420
|
routes = @controller.respond_to?(:_routes) && @controller._routes
|
|
422
421
|
rescue
|
|
@@ -426,16 +425,15 @@ module ActionView
|
|
|
426
425
|
if routes &&
|
|
427
426
|
(routes.named_routes.route_defined?(selector) ||
|
|
428
427
|
routes.mounted_helpers.method_defined?(selector))
|
|
429
|
-
@controller.__send__(selector,
|
|
428
|
+
@controller.__send__(selector, ...)
|
|
430
429
|
else
|
|
431
430
|
super
|
|
432
431
|
end
|
|
433
432
|
end
|
|
434
|
-
ruby2_keywords(:method_missing)
|
|
435
433
|
|
|
436
434
|
def respond_to_missing?(name, include_private = false)
|
|
437
435
|
begin
|
|
438
|
-
routes =
|
|
436
|
+
routes = @controller.respond_to?(:_routes) && @controller._routes
|
|
439
437
|
rescue
|
|
440
438
|
# Don't call routes, if there is an error on _routes call
|
|
441
439
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: actionview
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 7.
|
|
4
|
+
version: 7.2.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Heinemeier Hansson
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: activesupport
|
|
@@ -16,14 +15,14 @@ dependencies:
|
|
|
16
15
|
requirements:
|
|
17
16
|
- - '='
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 7.
|
|
18
|
+
version: 7.2.2.2
|
|
20
19
|
type: :runtime
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
23
|
- - '='
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 7.
|
|
25
|
+
version: 7.2.2.2
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
28
27
|
name: builder
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -86,28 +85,28 @@ dependencies:
|
|
|
86
85
|
requirements:
|
|
87
86
|
- - '='
|
|
88
87
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: 7.
|
|
88
|
+
version: 7.2.2.2
|
|
90
89
|
type: :development
|
|
91
90
|
prerelease: false
|
|
92
91
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
92
|
requirements:
|
|
94
93
|
- - '='
|
|
95
94
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: 7.
|
|
95
|
+
version: 7.2.2.2
|
|
97
96
|
- !ruby/object:Gem::Dependency
|
|
98
97
|
name: activemodel
|
|
99
98
|
requirement: !ruby/object:Gem::Requirement
|
|
100
99
|
requirements:
|
|
101
100
|
- - '='
|
|
102
101
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: 7.
|
|
102
|
+
version: 7.2.2.2
|
|
104
103
|
type: :development
|
|
105
104
|
prerelease: false
|
|
106
105
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
106
|
requirements:
|
|
108
107
|
- - '='
|
|
109
108
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: 7.
|
|
109
|
+
version: 7.2.2.2
|
|
111
110
|
description: Simple, battle-tested conventions and helpers for building web pages.
|
|
112
111
|
email: david@loudthinking.com
|
|
113
112
|
executables: []
|
|
@@ -126,7 +125,7 @@ files:
|
|
|
126
125
|
- lib/action_view/context.rb
|
|
127
126
|
- lib/action_view/dependency_tracker.rb
|
|
128
127
|
- lib/action_view/dependency_tracker/erb_tracker.rb
|
|
129
|
-
- lib/action_view/dependency_tracker/
|
|
128
|
+
- lib/action_view/dependency_tracker/ruby_tracker.rb
|
|
130
129
|
- lib/action_view/deprecator.rb
|
|
131
130
|
- lib/action_view/digestor.rb
|
|
132
131
|
- lib/action_view/flows.rb
|
|
@@ -204,6 +203,8 @@ files:
|
|
|
204
203
|
- lib/action_view/railtie.rb
|
|
205
204
|
- lib/action_view/record_identifier.rb
|
|
206
205
|
- lib/action_view/render_parser.rb
|
|
206
|
+
- lib/action_view/render_parser/prism_render_parser.rb
|
|
207
|
+
- lib/action_view/render_parser/ripper_render_parser.rb
|
|
207
208
|
- lib/action_view/renderer/abstract_renderer.rb
|
|
208
209
|
- lib/action_view/renderer/collection_renderer.rb
|
|
209
210
|
- lib/action_view/renderer/object_renderer.rb
|
|
@@ -213,7 +214,6 @@ files:
|
|
|
213
214
|
- lib/action_view/renderer/streaming_template_renderer.rb
|
|
214
215
|
- lib/action_view/renderer/template_renderer.rb
|
|
215
216
|
- lib/action_view/rendering.rb
|
|
216
|
-
- lib/action_view/ripper_ast_parser.rb
|
|
217
217
|
- lib/action_view/routing_url_for.rb
|
|
218
218
|
- lib/action_view/tasks/cache_digests.rake
|
|
219
219
|
- lib/action_view/template.rb
|
|
@@ -245,12 +245,11 @@ licenses:
|
|
|
245
245
|
- MIT
|
|
246
246
|
metadata:
|
|
247
247
|
bug_tracker_uri: https://github.com/rails/rails/issues
|
|
248
|
-
changelog_uri: https://github.com/rails/rails/blob/v7.
|
|
249
|
-
documentation_uri: https://api.rubyonrails.org/v7.
|
|
248
|
+
changelog_uri: https://github.com/rails/rails/blob/v7.2.2.2/actionview/CHANGELOG.md
|
|
249
|
+
documentation_uri: https://api.rubyonrails.org/v7.2.2.2/
|
|
250
250
|
mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
|
|
251
|
-
source_code_uri: https://github.com/rails/rails/tree/v7.
|
|
251
|
+
source_code_uri: https://github.com/rails/rails/tree/v7.2.2.2/actionview
|
|
252
252
|
rubygems_mfa_required: 'true'
|
|
253
|
-
post_install_message:
|
|
254
253
|
rdoc_options: []
|
|
255
254
|
require_paths:
|
|
256
255
|
- lib
|
|
@@ -258,7 +257,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
258
257
|
requirements:
|
|
259
258
|
- - ">="
|
|
260
259
|
- !ruby/object:Gem::Version
|
|
261
|
-
version:
|
|
260
|
+
version: 3.1.0
|
|
262
261
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
263
262
|
requirements:
|
|
264
263
|
- - ">="
|
|
@@ -266,8 +265,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
266
265
|
version: '0'
|
|
267
266
|
requirements:
|
|
268
267
|
- none
|
|
269
|
-
rubygems_version: 3.
|
|
270
|
-
signing_key:
|
|
268
|
+
rubygems_version: 3.6.9
|
|
271
269
|
specification_version: 4
|
|
272
270
|
summary: Rendering framework putting the V in MVC (part of Rails).
|
|
273
271
|
test_files: []
|