actionview 7.1.4 → 7.2.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +42 -437
- data/lib/action_view/base.rb +19 -1
- 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 +18 -6
- 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 +76 -43
- 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/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 +26 -3
- data/lib/action_view/test_case.rb +7 -9
- data/lib/assets/compiled/rails-ujs.js +777 -0
- metadata +17 -15
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
|
@@ -424,9 +438,13 @@ module ActionView
|
|
424
438
|
|
425
439
|
method_arguments =
|
426
440
|
if set_strict_locals
|
427
|
-
|
441
|
+
if set_strict_locals.include?("&")
|
442
|
+
"output_buffer, #{set_strict_locals}"
|
443
|
+
else
|
444
|
+
"output_buffer, #{set_strict_locals}, &_"
|
445
|
+
end
|
428
446
|
else
|
429
|
-
"local_assigns, output_buffer"
|
447
|
+
"local_assigns, output_buffer, &_"
|
430
448
|
end
|
431
449
|
|
432
450
|
# Make sure that the resulting String to be eval'd is in the
|
@@ -491,6 +509,8 @@ module ActionView
|
|
491
509
|
![:keyreq, :key, :keyrest, :nokey].include?(parameter[0])
|
492
510
|
end
|
493
511
|
|
512
|
+
non_kwarg_parameters.pop if non_kwarg_parameters.last == %i(block _)
|
513
|
+
|
494
514
|
unless non_kwarg_parameters.empty?
|
495
515
|
mod.undef_method(method_name)
|
496
516
|
|
@@ -525,12 +545,15 @@ module ActionView
|
|
525
545
|
end
|
526
546
|
end
|
527
547
|
|
548
|
+
RUBY_RESERVED_KEYWORDS = ::ActiveSupport::Delegation::RUBY_RESERVED_KEYWORDS
|
549
|
+
private_constant :RUBY_RESERVED_KEYWORDS
|
550
|
+
|
528
551
|
def locals_code
|
529
552
|
return "" if strict_locals?
|
530
553
|
|
531
554
|
# Only locals with valid variable names get set directly. Others will
|
532
555
|
# still be available in local_assigns.
|
533
|
-
locals = @locals -
|
556
|
+
locals = @locals - RUBY_RESERVED_KEYWORDS
|
534
557
|
|
535
558
|
locals = locals.grep(/\A(?![A-Z0-9])(?:[[:alnum:]_]|[^\0-\177])+\z/)
|
536
559
|
|
@@ -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
|