actionview 7.1.5.1 → 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 +41 -456
- 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 +6 -82
- 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 +18 -1
- data/lib/action_view/test_case.rb +7 -9
- data/lib/assets/compiled/rails-ujs.js +777 -0
- metadata +20 -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
|
@@ -531,12 +545,15 @@ module ActionView
|
|
531
545
|
end
|
532
546
|
end
|
533
547
|
|
548
|
+
RUBY_RESERVED_KEYWORDS = ::ActiveSupport::Delegation::RUBY_RESERVED_KEYWORDS
|
549
|
+
private_constant :RUBY_RESERVED_KEYWORDS
|
550
|
+
|
534
551
|
def locals_code
|
535
552
|
return "" if strict_locals?
|
536
553
|
|
537
554
|
# Only locals with valid variable names get set directly. Others will
|
538
555
|
# still be available in local_assigns.
|
539
|
-
locals = @locals -
|
556
|
+
locals = @locals - RUBY_RESERVED_KEYWORDS
|
540
557
|
|
541
558
|
locals = locals.grep(/\A(?![A-Z0-9])(?:[[:alnum:]_]|[^\0-\177])+\z/)
|
542
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
|