diff options
Diffstat (limited to 'actionpack/lib/action_view/base.rb')
-rw-r--r-- | actionpack/lib/action_view/base.rb | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index cde1c36bd9..1890259ca0 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -131,7 +131,7 @@ module ActionView #:nodoc: # # More builder documentation can be found at http://builder.rubyforge.org. class Base - include Helpers, ::ERB::Util, Context + include Helpers, Rendering, ::ERB::Util, Context # Specify the proc used to decorate input tags that refer to attributes with errors. cattr_accessor :field_error_proc @@ -162,7 +162,7 @@ module ActionView #:nodoc: attr_accessor :view_renderer attr_internal :request, :controller, :config, :assigns - delegate :lookup_context, :render, :render_body, :to => :view_renderer + delegate :lookup_context, :to => :view_renderer delegate :formats, :formats=, :locale, :locale=, :view_paths, :view_paths=, :to => :lookup_context delegate :request_forgery_protection_token, :params, :session, :cookies, :response, :headers, @@ -183,10 +183,11 @@ module ActionView #:nodoc: @_assigns = new_assigns.each { |key, value| instance_variable_set("@#{key}", value) } end - def initialize(lookup_context = nil, assigns_for_first_render = {}, controller = nil, formats = nil) #:nodoc: + def initialize(context = nil, assigns_for_first_render = {}, controller = nil, formats = nil) #:nodoc: assign(assigns_for_first_render) self.helpers = Module.new unless self.class.helpers + # Context vars initialization @view_flow = OutputFlow.new @output_buffer = nil @virtual_path = nil @@ -197,13 +198,19 @@ module ActionView #:nodoc: @_config = controller.config.inheritable_copy if controller.respond_to?(:config) end - _lookup_context = lookup_context.is_a?(ActionView::LookupContext) ? - lookup_context : ActionView::LookupContext.new(lookup_context) - _lookup_context.formats = formats if formats - - @view_renderer = ActionView::Renderer.new(_lookup_context, self) + # Handle all these for backwards compatibility. + # TODO Provide a new API for AV::Base and deprecate this one. + if context.is_a?(ActionView::Renderer) + @view_renderer = context + elsif + lookup_context = context.is_a?(ActionView::LookupContext) ? + context : ActionView::LookupContext.new(context) + lookup_context.formats = formats if formats + @view_renderer = ActionView::Renderer.new(lookup_context, controller) + end end + # TODO Is this needed anywhere? Maybe deprecate it? def controller_path @controller_path ||= controller && controller.controller_path end |