aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib
diff options
context:
space:
mode:
Diffstat (limited to 'actionview/lib')
-rw-r--r--actionview/lib/action_view/base.rb6
-rw-r--r--actionview/lib/action_view/helpers/form_helper.rb4
-rw-r--r--actionview/lib/action_view/helpers/output_safety_helper.rb2
-rw-r--r--actionview/lib/action_view/helpers/translation_helper.rb4
-rw-r--r--actionview/lib/action_view/lookup_context.rb2
-rw-r--r--actionview/lib/action_view/rendering.rb3
-rw-r--r--actionview/lib/action_view/template.rb5
-rw-r--r--actionview/lib/action_view/template/resolver.rb8
-rw-r--r--actionview/lib/action_view/testing/resolvers.rb4
9 files changed, 17 insertions, 21 deletions
diff --git a/actionview/lib/action_view/base.rb b/actionview/lib/action_view/base.rb
index c4565ca272..cf71b4803b 100644
--- a/actionview/lib/action_view/base.rb
+++ b/actionview/lib/action_view/base.rb
@@ -242,7 +242,7 @@ module ActionView #:nodoc:
@_config = ActiveSupport::InheritableOptions.new
unless formats == NULL
- ActiveSupport::Deprecation.warn <<~eowarn
+ ActiveSupport::Deprecation.warn <<~eowarn.squish
Passing formats to ActionView::Base.new is deprecated
eowarn
end
@@ -251,7 +251,7 @@ module ActionView #:nodoc:
when ActionView::LookupContext
@lookup_context = lookup_context
else
- ActiveSupport::Deprecation.warn <<~eowarn
+ ActiveSupport::Deprecation.warn <<~eowarn.squish
ActionView::Base instances should be constructed with a lookup context,
assignments, and a controller.
eowarn
@@ -278,7 +278,7 @@ module ActionView #:nodoc:
def compiled_method_container
if self.class == ActionView::Base
- ActiveSupport::Deprecation.warn <<~eowarn
+ ActiveSupport::Deprecation.warn <<~eowarn.squish
ActionView::Base instances must implement `compiled_method_container`
or use the class method `with_empty_template_cache` for constructing
an ActionView::Base instances that has an empty cache.
diff --git a/actionview/lib/action_view/helpers/form_helper.rb b/actionview/lib/action_view/helpers/form_helper.rb
index c5a736bfb4..5533cef249 100644
--- a/actionview/lib/action_view/helpers/form_helper.rb
+++ b/actionview/lib/action_view/helpers/form_helper.rb
@@ -739,7 +739,7 @@ module ActionView
# def labelled_form_with(**options, &block)
# form_with(**options.merge(builder: LabellingFormBuilder), &block)
# end
- def form_with(model: nil, scope: nil, url: nil, format: nil, **options)
+ def form_with(model: nil, scope: nil, url: nil, format: nil, **options, &block)
options[:allow_method_names_outside_object] = true
options[:skip_default_ids] = !form_with_generates_ids
@@ -752,7 +752,7 @@ module ActionView
if block_given?
builder = instantiate_builder(scope, model, options)
- output = capture(builder, &Proc.new)
+ output = capture(builder, &block)
options[:multipart] ||= builder.multipart?
html_options = html_options_for_form_with(url, model, options)
diff --git a/actionview/lib/action_view/helpers/output_safety_helper.rb b/actionview/lib/action_view/helpers/output_safety_helper.rb
index 279cde5e76..52a951b2ca 100644
--- a/actionview/lib/action_view/helpers/output_safety_helper.rb
+++ b/actionview/lib/action_view/helpers/output_safety_helper.rb
@@ -38,7 +38,7 @@ module ActionView #:nodoc:
# Converts the array to a comma-separated sentence where the last element is
# joined by the connector word. This is the html_safe-aware version of
- # ActiveSupport's {Array#to_sentence}[http://api.rubyonrails.org/classes/Array.html#method-i-to_sentence].
+ # ActiveSupport's {Array#to_sentence}[https://api.rubyonrails.org/classes/Array.html#method-i-to_sentence].
#
def to_sentence(array, options = {})
options.assert_valid_keys(:words_connector, :two_words_connector, :last_word_connector, :locale)
diff --git a/actionview/lib/action_view/helpers/translation_helper.rb b/actionview/lib/action_view/helpers/translation_helper.rb
index 67c86592b9..d5b0a9263f 100644
--- a/actionview/lib/action_view/helpers/translation_helper.rb
+++ b/actionview/lib/action_view/helpers/translation_helper.rb
@@ -114,7 +114,7 @@ module ActionView
# Delegates to <tt>I18n.localize</tt> with no additional functionality.
#
- # See http://rubydoc.info/github/svenfuchs/i18n/master/I18n/Backend/Base:localize
+ # See https://www.rubydoc.info/github/svenfuchs/i18n/master/I18n/Backend/Base:localize
# for more information.
def localize(*args)
I18n.localize(*args)
@@ -138,7 +138,7 @@ module ActionView
end
def html_safe_translation_key?(key)
- /([_.]|\b)html\z/.match?(key.to_s)
+ /(?:_|\b)html\z/.match?(key.to_s)
end
end
end
diff --git a/actionview/lib/action_view/lookup_context.rb b/actionview/lib/action_view/lookup_context.rb
index 10cd61bbd6..2eaf188ecf 100644
--- a/actionview/lib/action_view/lookup_context.rb
+++ b/actionview/lib/action_view/lookup_context.rb
@@ -154,7 +154,7 @@ module ActionView
view_paths = build_view_paths((@view_paths.paths + self.class.fallbacks).uniq)
if block_given?
- ActiveSupport::Deprecation.warn <<~eowarn
+ ActiveSupport::Deprecation.warn <<~eowarn.squish
Calling `with_fallbacks` with a block is deprecated. Call methods on
the lookup context returned by `with_fallbacks` instead.
eowarn
diff --git a/actionview/lib/action_view/rendering.rb b/actionview/lib/action_view/rendering.rb
index e5e2771323..ac861c44d4 100644
--- a/actionview/lib/action_view/rendering.rb
+++ b/actionview/lib/action_view/rendering.rb
@@ -118,7 +118,8 @@ module ActionView
renderer.render_to_object(context, options)
end
- @rendered_format = Template::Types[rendered_template.format]
+ rendered_format = rendered_template.format || lookup_context.formats.first
+ @rendered_format = Template::Types[rendered_format]
rendered_template.body
end
diff --git a/actionview/lib/action_view/template.rb b/actionview/lib/action_view/template.rb
index 7f29dedd7c..2c27e11b9e 100644
--- a/actionview/lib/action_view/template.rb
+++ b/actionview/lib/action_view/template.rb
@@ -126,11 +126,6 @@ module ActionView
attr_reader :variable, :format, :variant, :locals, :virtual_path
def initialize(source, identifier, handler, format: nil, variant: nil, locals: nil, virtual_path: nil, updated_at: Time.now)
- unless format
- ActiveSupport::Deprecation.warn "ActionView::Template#initialize requires a format parameter"
- format = :html
- end
-
unless locals
ActiveSupport::Deprecation.warn "ActionView::Template#initialize requires a locals parameter"
locals = []
diff --git a/actionview/lib/action_view/template/resolver.rb b/actionview/lib/action_view/template/resolver.rb
index 1c463efbb2..1dc9c9919a 100644
--- a/actionview/lib/action_view/template/resolver.rb
+++ b/actionview/lib/action_view/template/resolver.rb
@@ -212,7 +212,7 @@ module ActionView
template_paths = reject_files_external_to_app(template_paths) unless outside_app_allowed
template_paths.map do |template|
- handler, format, variant = extract_handler_and_format_and_variant(template, formats.first)
+ handler, format, variant = extract_handler_and_format_and_variant(template)
FileTemplate.new(File.expand_path(template), handler,
virtual_path: path.virtual,
@@ -280,7 +280,7 @@ module ActionView
# Extract handler, formats and variant from path. If a format cannot be found neither
# from the path, or the handler, we should return the array of formats given
# to the resolver.
- def extract_handler_and_format_and_variant(path, query_format)
+ def extract_handler_and_format_and_variant(path)
pieces = File.basename(path).split(".")
pieces.shift
@@ -294,12 +294,12 @@ module ActionView
if handler.respond_to?(:default_format) # default_format can return nil
handler.default_format
else
- query_format
+ nil
end
end
# Template::Types[format] and handler.default_format can return nil
- [handler, format || query_format, variant]
+ [handler, format, variant]
end
end
diff --git a/actionview/lib/action_view/testing/resolvers.rb b/actionview/lib/action_view/testing/resolvers.rb
index 2305fc9b81..3ca8420c6c 100644
--- a/actionview/lib/action_view/testing/resolvers.rb
+++ b/actionview/lib/action_view/testing/resolvers.rb
@@ -34,7 +34,7 @@ module ActionView #:nodoc:
@hash.each do |_path, array|
source, updated_at = array
next unless query.match?(_path)
- handler, format, variant = extract_handler_and_format_and_variant(_path, :html)
+ handler, format, variant = extract_handler_and_format_and_variant(_path)
templates << Template.new(source, _path, handler,
virtual_path: path.virtual,
format: format,
@@ -50,7 +50,7 @@ module ActionView #:nodoc:
class NullResolver < PathResolver
def query(path, exts, _, _, locals)
- handler, format, variant = extract_handler_and_format_and_variant(path, :html)
+ handler, format, variant = extract_handler_and_format_and_variant(path)
[ActionView::Template.new("Template generated by Null Resolver", path.virtual, handler, virtual_path: path.virtual, format: format, variant: variant, locals: locals)]
end
end