actionview 6.0.3.3 → 6.1.1

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 (63) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +177 -208
  3. data/MIT-LICENSE +1 -1
  4. data/lib/action_view.rb +4 -1
  5. data/lib/action_view/base.rb +19 -50
  6. data/lib/action_view/cache_expiry.rb +1 -2
  7. data/lib/action_view/dependency_tracker.rb +10 -4
  8. data/lib/action_view/digestor.rb +3 -2
  9. data/lib/action_view/gem_version.rb +3 -3
  10. data/lib/action_view/helpers/asset_tag_helper.rb +55 -15
  11. data/lib/action_view/helpers/asset_url_helper.rb +6 -4
  12. data/lib/action_view/helpers/atom_feed_helper.rb +2 -1
  13. data/lib/action_view/helpers/cache_helper.rb +10 -16
  14. data/lib/action_view/helpers/date_helper.rb +4 -4
  15. data/lib/action_view/helpers/form_helper.rb +66 -30
  16. data/lib/action_view/helpers/form_options_helper.rb +7 -16
  17. data/lib/action_view/helpers/form_tag_helper.rb +7 -7
  18. data/lib/action_view/helpers/javascript_helper.rb +3 -3
  19. data/lib/action_view/helpers/number_helper.rb +6 -6
  20. data/lib/action_view/helpers/rendering_helper.rb +11 -3
  21. data/lib/action_view/helpers/sanitize_helper.rb +2 -2
  22. data/lib/action_view/helpers/tag_helper.rb +92 -17
  23. data/lib/action_view/helpers/tags/base.rb +9 -5
  24. data/lib/action_view/helpers/tags/date_field.rb +1 -1
  25. data/lib/action_view/helpers/tags/date_select.rb +2 -2
  26. data/lib/action_view/helpers/tags/datetime_local_field.rb +1 -1
  27. data/lib/action_view/helpers/tags/label.rb +4 -0
  28. data/lib/action_view/helpers/tags/month_field.rb +1 -1
  29. data/lib/action_view/helpers/tags/select.rb +1 -1
  30. data/lib/action_view/helpers/tags/time_field.rb +1 -1
  31. data/lib/action_view/helpers/tags/week_field.rb +1 -1
  32. data/lib/action_view/helpers/text_helper.rb +1 -1
  33. data/lib/action_view/helpers/translation_helper.rb +87 -51
  34. data/lib/action_view/helpers/url_helper.rb +107 -13
  35. data/lib/action_view/layouts.rb +3 -2
  36. data/lib/action_view/log_subscriber.rb +26 -10
  37. data/lib/action_view/lookup_context.rb +3 -18
  38. data/lib/action_view/path_set.rb +0 -3
  39. data/lib/action_view/railtie.rb +39 -46
  40. data/lib/action_view/renderer/abstract_renderer.rb +93 -14
  41. data/lib/action_view/renderer/collection_renderer.rb +196 -0
  42. data/lib/action_view/renderer/object_renderer.rb +34 -0
  43. data/lib/action_view/renderer/partial_renderer.rb +20 -282
  44. data/lib/action_view/renderer/partial_renderer/collection_caching.rb +25 -26
  45. data/lib/action_view/renderer/renderer.rb +44 -1
  46. data/lib/action_view/renderer/streaming_template_renderer.rb +5 -1
  47. data/lib/action_view/renderer/template_renderer.rb +15 -12
  48. data/lib/action_view/rendering.rb +3 -1
  49. data/lib/action_view/routing_url_for.rb +1 -1
  50. data/lib/action_view/template.rb +9 -49
  51. data/lib/action_view/template/handlers.rb +0 -26
  52. data/lib/action_view/template/handlers/erb.rb +10 -14
  53. data/lib/action_view/template/handlers/erb/erubi.rb +9 -7
  54. data/lib/action_view/template/html.rb +1 -11
  55. data/lib/action_view/template/raw_file.rb +0 -3
  56. data/lib/action_view/template/renderable.rb +24 -0
  57. data/lib/action_view/template/resolver.rb +82 -40
  58. data/lib/action_view/template/text.rb +0 -3
  59. data/lib/action_view/test_case.rb +18 -25
  60. data/lib/action_view/testing/resolvers.rb +10 -31
  61. data/lib/action_view/unbound_template.rb +3 -3
  62. data/lib/action_view/view_paths.rb +34 -36
  63. metadata +18 -15
@@ -45,7 +45,7 @@ module ActionView
45
45
  def _back_url # :nodoc:
46
46
  _filtered_referrer || "javascript:history.back()"
47
47
  end
48
- protected :_back_url
48
+ private :_back_url
49
49
 
50
50
  def _filtered_referrer # :nodoc:
51
51
  if controller.respond_to?(:request)
@@ -56,12 +56,12 @@ module ActionView
56
56
  end
57
57
  rescue URI::InvalidURIError
58
58
  end
59
- protected :_filtered_referrer
59
+ private :_filtered_referrer
60
60
 
61
61
  # Creates an anchor element of the given +name+ using a URL created by the set of +options+.
62
62
  # See the valid options in the documentation for +url_for+. It's also possible to
63
- # pass a String instead of an options hash, which generates an anchor element that uses the
64
- # value of the String as the href for the link. Using a <tt>:back</tt> Symbol instead
63
+ # pass a \String instead of an options hash, which generates an anchor element that uses the
64
+ # value of the \String as the href for the link. Using a <tt>:back</tt> \Symbol instead
65
65
  # of an options hash will generate a link to the referrer (a JavaScript back link
66
66
  # will be used in place of a referrer if none exists). If +nil+ is passed as the name
67
67
  # the value of the link itself will become the name.
@@ -177,7 +177,7 @@ module ActionView
177
177
  # # => <a href="/searches?query=ruby+on+rails">Ruby on Rails search</a>
178
178
  #
179
179
  # link_to "Nonsense search", searches_path(foo: "bar", baz: "quux")
180
- # # => <a href="/searches?foo=bar&amp;baz=quux">Nonsense search</a>
180
+ # # => <a href="/searches?foo=bar&baz=quux">Nonsense search</a>
181
181
  #
182
182
  # The only option specific to +link_to+ (<tt>:method</tt>) is used as follows:
183
183
  #
@@ -226,7 +226,7 @@ module ActionView
226
226
  # The +options+ hash accepts the same options as +url_for+.
227
227
  #
228
228
  # There are a few special +html_options+:
229
- # * <tt>:method</tt> - Symbol of HTTP verb. Supported verbs are <tt>:post</tt>, <tt>:get</tt>,
229
+ # * <tt>:method</tt> - \Symbol of HTTP verb. Supported verbs are <tt>:post</tt>, <tt>:get</tt>,
230
230
  # <tt>:delete</tt>, <tt>:patch</tt>, and <tt>:put</tt>. By default it will be <tt>:post</tt>.
231
231
  # * <tt>:disabled</tt> - If set to true, it will generate a disabled button.
232
232
  # * <tt>:data</tt> - This option can be used to add custom data attributes.
@@ -235,7 +235,7 @@ module ActionView
235
235
  # * <tt>:form</tt> - This hash will be form attributes
236
236
  # * <tt>:form_class</tt> - This controls the class of the form within which the submit button will
237
237
  # be placed
238
- # * <tt>:params</tt> - Hash of parameters to be rendered as hidden fields within the form.
238
+ # * <tt>:params</tt> - \Hash of parameters to be rendered as hidden fields within the form.
239
239
  #
240
240
  # ==== Data attributes
241
241
  #
@@ -290,7 +290,7 @@ module ActionView
290
290
  #
291
291
  #
292
292
  # <%= button_to('Destroy', 'http://www.example.com',
293
- # method: "delete", remote: true, data: { confirm: 'Are you sure?', disable_with: 'loading...' }) %>
293
+ # method: :delete, remote: true, data: { confirm: 'Are you sure?', disable_with: 'loading...' }) %>
294
294
  # # => "<form class='button_to' method='post' action='http://www.example.com' data-remote='true'>
295
295
  # # <input name='_method' value='delete' type='hidden' />
296
296
  # # <input value='Destroy' type='submit' data-disable-with='loading...' data-confirm='Are you sure?' />
@@ -412,8 +412,7 @@ module ActionView
412
412
  # Creates a link tag of the given +name+ using a URL created by the set of
413
413
  # +options+ if +condition+ is true, otherwise only the name is
414
414
  # returned. To specialize the default behavior, you can pass a block that
415
- # accepts the name or the full argument list for +link_to_unless+ (see the examples
416
- # in +link_to_unless+).
415
+ # accepts the name or the full argument list for +link_to_if+.
417
416
  #
418
417
  # ==== Examples
419
418
  # <%= link_to_if(@current_user.nil?, "Login", { controller: "sessions", action: "new" }) %>
@@ -550,14 +549,14 @@ module ActionView
550
549
  return false unless request.get? || request.head?
551
550
 
552
551
  check_parameters ||= options.is_a?(Hash) && options.delete(:check_parameters)
553
- url_string = URI.parser.unescape(url_for(options)).force_encoding(Encoding::BINARY)
552
+ url_string = URI::DEFAULT_PARSER.unescape(url_for(options)).force_encoding(Encoding::BINARY)
554
553
 
555
554
  # We ignore any extra parameters in the request_uri if the
556
555
  # submitted URL doesn't have any either. This lets the function
557
556
  # work with things like ?order=asc
558
557
  # the behaviour can be disabled with check_parameters: true
559
558
  request_uri = url_string.index("?") || check_parameters ? request.fullpath : request.path
560
- request_uri = URI.parser.unescape(request_uri).force_encoding(Encoding::BINARY)
559
+ request_uri = URI::DEFAULT_PARSER.unescape(request_uri).force_encoding(Encoding::BINARY)
561
560
 
562
561
  if url_string.start_with?("/") && url_string != "/"
563
562
  url_string.chomp!("/")
@@ -571,6 +570,101 @@ module ActionView
571
570
  end
572
571
  end
573
572
 
573
+ # Creates an SMS anchor link tag to the specified +phone_number+, which is
574
+ # also used as the name of the link unless +name+ is specified. Additional
575
+ # HTML attributes for the link can be passed in +html_options+.
576
+ #
577
+ # When clicked, an SMS message is prepopulated with the passed phone number
578
+ # and optional +body+ value.
579
+ #
580
+ # +sms_to+ has a +body+ option for customizing the SMS message itself by
581
+ # passing special keys to +html_options+.
582
+ #
583
+ # ==== Options
584
+ # * <tt>:body</tt> - Preset the body of the message.
585
+ #
586
+ # ==== Examples
587
+ # sms_to "5155555785"
588
+ # # => <a href="sms:5155555785;">5155555785</a>
589
+ #
590
+ # sms_to "5155555785", "Text me"
591
+ # # => <a href="sms:5155555785;">Text me</a>
592
+ #
593
+ # sms_to "5155555785", "Text me",
594
+ # body: "Hello Jim I have a question about your product."
595
+ # # => <a href="sms:5155555785;?body=Hello%20Jim%20I%20have%20a%20question%20about%20your%20product">Text me</a>
596
+ #
597
+ # You can use a block as well if your link target is hard to fit into the name parameter. \ERB example:
598
+ #
599
+ # <%= sms_to "5155555785" do %>
600
+ # <strong>Text me:</strong>
601
+ # <% end %>
602
+ # # => <a href="sms:5155555785;">
603
+ # <strong>Text me:</strong>
604
+ # </a>
605
+ def sms_to(phone_number, name = nil, html_options = {}, &block)
606
+ html_options, name = name, nil if block_given?
607
+ html_options = (html_options || {}).stringify_keys
608
+
609
+ extras = %w{ body }.map! { |item|
610
+ option = html_options.delete(item).presence || next
611
+ "#{item.dasherize}=#{ERB::Util.url_encode(option)}"
612
+ }.compact
613
+ extras = extras.empty? ? "" : "?&" + extras.join("&")
614
+
615
+ encoded_phone_number = ERB::Util.url_encode(phone_number)
616
+ html_options["href"] = "sms:#{encoded_phone_number};#{extras}"
617
+
618
+ content_tag("a", name || phone_number, html_options, &block)
619
+ end
620
+
621
+ # Creates a TEL anchor link tag to the specified +phone_number+, which is
622
+ # also used as the name of the link unless +name+ is specified. Additional
623
+ # HTML attributes for the link can be passed in +html_options+.
624
+ #
625
+ # When clicked, the default app to make calls is opened, and it
626
+ # is prepopulated with the passed phone number and optional
627
+ # +country_code+ value.
628
+ #
629
+ # +phone_to+ has an optional +country_code+ option which automatically adds the country
630
+ # code as well as the + sign in the phone numer that gets prepopulated,
631
+ # for example if +country_code: "01"+ +\+01+ will be prepended to the
632
+ # phone numer, by passing special keys to +html_options+.
633
+ #
634
+ # ==== Options
635
+ # * <tt>:country_code</tt> - Prepends the country code to the number
636
+ #
637
+ # ==== Examples
638
+ # phone_to "1234567890"
639
+ # # => <a href="tel:1234567890">1234567890</a>
640
+ #
641
+ # phone_to "1234567890", "Phone me"
642
+ # # => <a href="tel:134567890">Phone me</a>
643
+ #
644
+ # phone_to "1234567890", "Phone me", country_code: "01"
645
+ # # => <a href="tel:+015155555785">Phone me</a>
646
+ #
647
+ # You can use a block as well if your link target is hard to fit into the name parameter. \ERB example:
648
+ #
649
+ # <%= phone_to "1234567890" do %>
650
+ # <strong>Phone me:</strong>
651
+ # <% end %>
652
+ # # => <a href="tel:1234567890">
653
+ # <strong>Phone me:</strong>
654
+ # </a>
655
+ def phone_to(phone_number, name = nil, html_options = {}, &block)
656
+ html_options, name = name, nil if block_given?
657
+ html_options = (html_options || {}).stringify_keys
658
+
659
+ country_code = html_options.delete("country_code").presence
660
+ country_code = country_code.nil? ? "" : "+#{ERB::Util.url_encode(country_code)}"
661
+
662
+ encoded_phone_number = ERB::Util.url_encode(phone_number)
663
+ html_options["href"] = "tel:#{country_code}#{encoded_phone_number}"
664
+
665
+ content_tag("a", name || phone_number, html_options, &block)
666
+ end
667
+
574
668
  private
575
669
  def convert_options_to_data_attributes(options, html_options)
576
670
  if html_options
@@ -594,7 +688,7 @@ module ActionView
594
688
  end
595
689
 
596
690
  def add_method_to_attributes!(html_options, method)
597
- if method_not_get_method?(method) && html_options["rel"] !~ /nofollow/
691
+ if method_not_get_method?(method) && !html_options["rel"]&.match?(/nofollow/)
598
692
  if html_options["rel"].blank?
599
693
  html_options["rel"] = "nofollow"
600
694
  else
@@ -306,7 +306,7 @@ module ActionView
306
306
  RUBY
307
307
  when Proc
308
308
  define_method :_layout_from_proc, &_layout
309
- protected :_layout_from_proc
309
+ private :_layout_from_proc
310
310
  <<-RUBY
311
311
  result = _layout_from_proc(#{_layout.arity == 0 ? '' : 'self'})
312
312
  return #{default_behavior} if result.nil?
@@ -321,6 +321,7 @@ module ActionView
321
321
  end
322
322
 
323
323
  class_eval <<-RUBY, __FILE__, __LINE__ + 1
324
+ # frozen_string_literal: true
324
325
  def _layout(lookup_context, formats)
325
326
  if _conditional_layout?
326
327
  #{layout_definition}
@@ -395,7 +396,7 @@ module ActionView
395
396
  end
396
397
 
397
398
  def _normalize_layout(value)
398
- value.is_a?(String) && value !~ /\blayouts/ ? "layouts/#{value}" : value
399
+ value.is_a?(String) && !value.match?(/\blayouts/) ? "layouts/#{value}" : value
399
400
  end
400
401
 
401
402
  # Returns the default layout for this controller.
@@ -23,7 +23,7 @@ module ActionView
23
23
  end
24
24
 
25
25
  def render_partial(event)
26
- info do
26
+ debug do
27
27
  message = +" Rendered #{from_rails_root(event.payload[:identifier])}"
28
28
  message << " within #{from_rails_root(event.payload[:layout])}" if event.payload[:layout]
29
29
  message << " (Duration: #{event.duration.round(1)}ms | Allocations: #{event.allocations})"
@@ -32,19 +32,26 @@ module ActionView
32
32
  end
33
33
  end
34
34
 
35
+ def render_layout(event)
36
+ info do
37
+ message = +" Rendered layout #{from_rails_root(event.payload[:identifier])}"
38
+ message << " (Duration: #{event.duration.round(1)}ms | Allocations: #{event.allocations})"
39
+ end
40
+ end
41
+
35
42
  def render_collection(event)
36
43
  identifier = event.payload[:identifier] || "templates"
37
44
 
38
- info do
39
- " Rendered collection of #{from_rails_root(identifier)}" \
40
- " #{render_count(event.payload)} (Duration: #{event.duration.round(1)}ms | Allocations: #{event.allocations})"
45
+ debug do
46
+ message = +" Rendered collection of #{from_rails_root(identifier)}"
47
+ message << " within #{from_rails_root(event.payload[:layout])}" if event.payload[:layout]
48
+ message << " #{render_count(event.payload)} (Duration: #{event.duration.round(1)}ms | Allocations: #{event.allocations})"
49
+ message
41
50
  end
42
51
  end
43
52
 
44
53
  def start(name, id, payload)
45
- if name == "render_template.action_view"
46
- log_rendering_start(payload)
47
- end
54
+ log_rendering_start(payload, name)
48
55
 
49
56
  super
50
57
  end
@@ -82,9 +89,18 @@ module ActionView
82
89
  end
83
90
  end
84
91
 
85
- def log_rendering_start(payload)
86
- info do
87
- message = +" Rendering #{from_rails_root(payload[:identifier])}"
92
+ def log_rendering_start(payload, name)
93
+ debug do
94
+ qualifier =
95
+ if name == "render_template.action_view"
96
+ ""
97
+ elsif name == "render_layout.action_view"
98
+ "layout "
99
+ end
100
+
101
+ return unless qualifier
102
+
103
+ message = +" Rendering #{qualifier}#{from_rails_root(payload[:identifier])}"
88
104
  message << " within #{from_rails_root(payload[:layout])}" if payload[:layout]
89
105
  message
90
106
  end
@@ -1,9 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "concurrent/map"
4
- require "active_support/core_ext/module/remove_method"
5
4
  require "active_support/core_ext/module/attribute_accessors"
6
- require "active_support/deprecation"
7
5
  require "action_view/template/resolver"
8
6
 
9
7
  module ActionView
@@ -16,8 +14,6 @@ module ActionView
16
14
  # only once during the request, it speeds up all cache accesses.
17
15
  class LookupContext #:nodoc:
18
16
  attr_accessor :prefixes, :rendered_format
19
- deprecate :rendered_format
20
- deprecate :rendered_format=
21
17
 
22
18
  mattr_accessor :fallbacks, default: FallbackFileSystemResolver.instances
23
19
 
@@ -30,7 +26,7 @@ module ActionView
30
26
  Accessors.define_method(:"default_#{name}", &block)
31
27
  Accessors.module_eval <<-METHOD, __FILE__, __LINE__ + 1
32
28
  def #{name}
33
- @details.fetch(:#{name}, [])
29
+ @details[:#{name}] || []
34
30
  end
35
31
 
36
32
  def #{name}=(value)
@@ -132,9 +128,6 @@ module ActionView
132
128
  end
133
129
  alias :find_template :find
134
130
 
135
- alias :find_file :find
136
- deprecate :find_file
137
-
138
131
  def find_all(name, prefixes = [], partial = false, keys = [], options = {})
139
132
  @view_paths.find_all(*args_for_lookup(name, prefixes, partial, keys, options))
140
133
  end
@@ -155,18 +148,10 @@ module ActionView
155
148
  view_paths = build_view_paths((@view_paths.paths + self.class.fallbacks).uniq)
156
149
 
157
150
  if block_given?
158
- ActiveSupport::Deprecation.warn <<~eowarn.squish
159
- Calling `with_fallbacks` with a block is deprecated. Call methods on
151
+ raise ArgumentError, <<~eowarn.squish
152
+ Calling `with_fallbacks` with a block is not supported. Call methods on
160
153
  the lookup context returned by `with_fallbacks` instead.
161
154
  eowarn
162
-
163
- begin
164
- _view_paths = @view_paths
165
- @view_paths = view_paths
166
- yield
167
- ensure
168
- @view_paths = _view_paths
169
- end
170
155
  else
171
156
  ActionView::LookupContext.new(view_paths, @details, @prefixes)
172
157
  end
@@ -48,9 +48,6 @@ module ActionView #:nodoc:
48
48
  find_all(*args).first || raise(MissingTemplate.new(self, *args))
49
49
  end
50
50
 
51
- alias :find_file :find
52
- deprecate :find_file
53
-
54
51
  def find_all(path, prefixes = [], *args)
55
52
  _find_all path, prefixes, args
56
53
  end
@@ -6,70 +6,59 @@ require "rails"
6
6
  module ActionView
7
7
  # = Action View Railtie
8
8
  class Railtie < Rails::Engine # :nodoc:
9
- NULL_OPTION = Object.new
10
-
11
9
  config.action_view = ActiveSupport::OrderedOptions.new
12
10
  config.action_view.embed_authenticity_token_in_remote_forms = nil
13
11
  config.action_view.debug_missing_translation = true
14
12
  config.action_view.default_enforce_utf8 = nil
15
- config.action_view.finalize_compiled_template_methods = NULL_OPTION
16
13
 
17
14
  config.eager_load_namespaces << ActionView
18
15
 
19
- initializer "action_view.embed_authenticity_token_in_remote_forms" do |app|
20
- ActiveSupport.on_load(:action_view) do
21
- ActionView::Helpers::FormTagHelper.embed_authenticity_token_in_remote_forms =
22
- app.config.action_view.delete(:embed_authenticity_token_in_remote_forms)
23
- end
16
+ config.after_initialize do |app|
17
+ ActionView::Helpers::FormTagHelper.embed_authenticity_token_in_remote_forms =
18
+ app.config.action_view.delete(:embed_authenticity_token_in_remote_forms)
24
19
  end
25
20
 
26
- initializer "action_view.form_with_generates_remote_forms" do |app|
27
- ActiveSupport.on_load(:action_view) do
28
- form_with_generates_remote_forms = app.config.action_view.delete(:form_with_generates_remote_forms)
29
- ActionView::Helpers::FormHelper.form_with_generates_remote_forms = form_with_generates_remote_forms
30
- end
21
+ config.after_initialize do |app|
22
+ form_with_generates_remote_forms = app.config.action_view.delete(:form_with_generates_remote_forms)
23
+ ActionView::Helpers::FormHelper.form_with_generates_remote_forms = form_with_generates_remote_forms
31
24
  end
32
25
 
33
- initializer "action_view.form_with_generates_ids" do |app|
34
- ActiveSupport.on_load(:action_view) do
35
- form_with_generates_ids = app.config.action_view.delete(:form_with_generates_ids)
36
- unless form_with_generates_ids.nil?
37
- ActionView::Helpers::FormHelper.form_with_generates_ids = form_with_generates_ids
38
- end
26
+ config.after_initialize do |app|
27
+ form_with_generates_ids = app.config.action_view.delete(:form_with_generates_ids)
28
+ unless form_with_generates_ids.nil?
29
+ ActionView::Helpers::FormHelper.form_with_generates_ids = form_with_generates_ids
39
30
  end
40
31
  end
41
32
 
42
- initializer "action_view.default_enforce_utf8" do |app|
43
- ActiveSupport.on_load(:action_view) do
44
- default_enforce_utf8 = app.config.action_view.delete(:default_enforce_utf8)
45
- unless default_enforce_utf8.nil?
46
- ActionView::Helpers::FormTagHelper.default_enforce_utf8 = default_enforce_utf8
47
- end
33
+ config.after_initialize do |app|
34
+ default_enforce_utf8 = app.config.action_view.delete(:default_enforce_utf8)
35
+ unless default_enforce_utf8.nil?
36
+ ActionView::Helpers::FormTagHelper.default_enforce_utf8 = default_enforce_utf8
48
37
  end
49
38
  end
50
39
 
51
- initializer "action_view.finalize_compiled_template_methods" do |app|
52
- ActiveSupport.on_load(:action_view) do
53
- option = app.config.action_view.delete(:finalize_compiled_template_methods)
54
-
55
- if option != NULL_OPTION
56
- ActiveSupport::Deprecation.warn "action_view.finalize_compiled_template_methods is deprecated and has no effect"
57
- end
58
- end
40
+ config.after_initialize do |app|
41
+ ActionView::Helpers::AssetTagHelper.preload_links_header = app.config.action_view.delete(:preload_links_header)
59
42
  end
60
43
 
61
- initializer "action_view.logger" do
62
- ActiveSupport.on_load(:action_view) { self.logger ||= Rails.logger }
63
- end
64
-
65
- initializer "action_view.set_configs" do |app|
44
+ config.after_initialize do |app|
66
45
  ActiveSupport.on_load(:action_view) do
67
46
  app.config.action_view.each do |k, v|
47
+ if k == :raise_on_missing_translations
48
+ ActiveSupport::Deprecation.warn \
49
+ "action_view.raise_on_missing_translations is deprecated and will be removed in Rails 6.2. " \
50
+ "Set i18n.raise_on_missing_translations instead. " \
51
+ "Note that this new setting also affects how missing translations are handled in controllers."
52
+ end
68
53
  send "#{k}=", v
69
54
  end
70
55
  end
71
56
  end
72
57
 
58
+ initializer "action_view.logger" do
59
+ ActiveSupport.on_load(:action_view) { self.logger ||= Rails.logger }
60
+ end
61
+
73
62
  initializer "action_view.caching" do |app|
74
63
  ActiveSupport.on_load(:action_view) do
75
64
  if app.config.action_view.cache_template_loading.nil?
@@ -78,14 +67,6 @@ module ActionView
78
67
  end
79
68
  end
80
69
 
81
- initializer "action_view.per_request_digest_cache" do |app|
82
- ActiveSupport.on_load(:action_view) do
83
- unless ActionView::Resolver.caching?
84
- app.executor.to_run ActionView::CacheExpiry::Executor.new(watcher: app.config.file_watcher)
85
- end
86
- end
87
- end
88
-
89
70
  initializer "action_view.setup_action_pack" do |app|
90
71
  ActiveSupport.on_load(:action_controller) do
91
72
  ActionView::RoutingUrlFor.include(ActionDispatch::Routing::UrlFor)
@@ -96,6 +77,18 @@ module ActionView
96
77
  PartialRenderer.collection_cache = app.config.action_controller.cache_store
97
78
  end
98
79
 
80
+ config.after_initialize do |app|
81
+ enable_caching = if app.config.action_view.cache_template_loading.nil?
82
+ app.config.cache_classes
83
+ else
84
+ app.config.action_view.cache_template_loading
85
+ end
86
+
87
+ unless enable_caching
88
+ app.executor.to_run ActionView::CacheExpiry::Executor.new(watcher: app.config.file_watcher)
89
+ end
90
+ end
91
+
99
92
  rake_tasks do |app|
100
93
  unless app.config.api_only
101
94
  load "action_view/tasks/cache_digests.rake"