diff options
Diffstat (limited to 'actionview/lib/action_view/template.rb')
-rw-r--r-- | actionview/lib/action_view/template.rb | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/actionview/lib/action_view/template.rb b/actionview/lib/action_view/template.rb index ca387e9229..2c27e11b9e 100644 --- a/actionview/lib/action_view/template.rb +++ b/actionview/lib/action_view/template.rb @@ -122,24 +122,21 @@ module ActionView extend Template::Handlers - attr_accessor :locals, :variants, :virtual_path - attr_reader :source, :identifier, :handler, :original_encoding, :updated_at - attr_reader :variable, :format + attr_reader :variable, :format, :variant, :locals, :virtual_path - def initialize(source, identifier, handler, format: nil, **details) - unless format - ActiveSupport::Deprecation.warn "ActionView::Template#initialize requires a format parameter" - format = :html + def initialize(source, identifier, handler, format: nil, variant: nil, locals: nil, virtual_path: nil, updated_at: Time.now) + unless locals + ActiveSupport::Deprecation.warn "ActionView::Template#initialize requires a locals parameter" + locals = [] end @source = source @identifier = identifier @handler = handler @compiled = false - @original_encoding = nil - @locals = details[:locals] || [] - @virtual_path = details[:virtual_path] + @locals = locals + @virtual_path = virtual_path @variable = if @virtual_path base = @virtual_path[-1] == "/" ? "" : File.basename(@virtual_path) @@ -147,17 +144,19 @@ module ActionView $1.to_sym end - @updated_at = details[:updated_at] || Time.now + @updated_at = updated_at @format = format - @variants = [details[:variant]] + @variant = variant @compile_mutex = Mutex.new end - def formats=(_) - end - deprecate :formats= - + deprecate :original_encoding + deprecate def virtual_path=(_); end + deprecate def locals=(_); end + 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, @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, @locals, @virtual_path, @updated_at, @format, @variant = *array @compile_mutex = Mutex.new end |