aboutsummaryrefslogtreecommitdiffstats
path: root/actionview
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@github.com>2019-02-25 15:11:12 -0800
committerGitHub <noreply@github.com>2019-02-25 15:11:12 -0800
commita92e5eb4ae566b973ebb6fcf85d9d4d6e6fffcb0 (patch)
tree23a7af8543cb1b2e3a3f87c8d24eb5f4f1dc50f3 /actionview
parent5e6e505083c2b0caf85b2f86c6be3ff3d8750857 (diff)
parentda8cb4fa3d9bc7d7a801578393b0cca37538c108 (diff)
downloadrails-a92e5eb4ae566b973ebb6fcf85d9d4d6e6fffcb0.tar.gz
rails-a92e5eb4ae566b973ebb6fcf85d9d4d6e6fffcb0.tar.bz2
rails-a92e5eb4ae566b973ebb6fcf85d9d4d6e6fffcb0.zip
Merge pull request #35408 from rails/template-has-one-variant
Template has one variant
Diffstat (limited to 'actionview')
-rw-r--r--actionview/lib/action_view/file_template.rb4
-rw-r--r--actionview/lib/action_view/template.rb19
-rw-r--r--actionview/lib/action_view/template/resolver.rb1
3 files changed, 11 insertions, 13 deletions
diff --git a/actionview/lib/action_view/file_template.rb b/actionview/lib/action_view/file_template.rb
index 43206f02e5..cdc077a01a 100644
--- a/actionview/lib/action_view/file_template.rb
+++ b/actionview/lib/action_view/file_template.rb
@@ -22,11 +22,11 @@ module ActionView
# to ensure that references to the template object can be marshalled as well. This means forgoing
# the marshalling of the compiler mutex and instantiating that again on unmarshalling.
def marshal_dump # :nodoc:
- [ @identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @format, @variants ]
+ [ @identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @format, @variant ]
end
def marshal_load(array) # :nodoc:
- @identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @format, @variants = *array
+ @identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @format, @variant = *array
@compile_mutex = Mutex.new
end
end
diff --git a/actionview/lib/action_view/template.rb b/actionview/lib/action_view/template.rb
index ca387e9229..f67c90de76 100644
--- a/actionview/lib/action_view/template.rb
+++ b/actionview/lib/action_view/template.rb
@@ -122,12 +122,12 @@ module ActionView
extend Template::Handlers
- attr_accessor :locals, :variants, :virtual_path
+ attr_accessor :locals, :virtual_path
attr_reader :source, :identifier, :handler, :original_encoding, :updated_at
- attr_reader :variable, :format
+ attr_reader :variable, :format, :variant
- def initialize(source, identifier, handler, format: nil, **details)
+ def initialize(source, identifier, handler, format: nil, variant: nil, **details)
unless format
ActiveSupport::Deprecation.warn "ActionView::Template#initialize requires a format parameter"
format = :html
@@ -149,15 +149,14 @@ module ActionView
@updated_at = details[:updated_at] || Time.now
@format = format
- @variants = [details[:variant]]
+ @variant = variant
@compile_mutex = Mutex.new
end
- def formats=(_)
- end
- deprecate :formats=
-
+ deprecate def formats=(_); end
deprecate def formats; Array(format); end
+ deprecate def variants=(_); end
+ deprecate def variants; [variant]; end
# Returns whether the underlying handler supports streaming. If so,
# a streaming buffer *may* be passed when it starts rendering.
@@ -262,11 +261,11 @@ module ActionView
# to ensure that references to the template object can be marshalled as well. This means forgoing
# the marshalling of the compiler mutex and instantiating that again on unmarshalling.
def marshal_dump # :nodoc:
- [ @source, @identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @format, @variants ]
+ [ @source, @identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @format, @variant ]
end
def marshal_load(array) # :nodoc:
- @source, @identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @format, @variants = *array
+ @source, @identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @format, @variant = *array
@compile_mutex = Mutex.new
end
diff --git a/actionview/lib/action_view/template/resolver.rb b/actionview/lib/action_view/template/resolver.rb
index 220794e443..6f0bf4187e 100644
--- a/actionview/lib/action_view/template/resolver.rb
+++ b/actionview/lib/action_view/template/resolver.rb
@@ -196,7 +196,6 @@ module ActionView
cached = nil
templates.each do |t|
t.locals = locals
- t.variants = details[:variants] || [] if t.variants.empty?
t.virtual_path ||= (cached ||= build_path(*path_info))
end
end