1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Replace _action_view with view_context to reflect that it is public and that it does not need to be an ActionView instance

This commit is contained in:
Yehuda Katz 2009-08-06 19:45:40 -03:00
parent f0945409d9
commit af375a5eb3
6 changed files with 10 additions and 11 deletions

View file

@ -13,7 +13,7 @@ class Kaigi < ActionController::Http
before_filter :set_name
append_view_path "views"
def _action_view
def view_context
self
end

View file

@ -31,8 +31,8 @@ module AbstractController
# partial<Boolean>:: Whether or not the template to render is a partial
#
# Override this method in a to change the default behavior.
def _action_view
@_action_view ||= ActionView::Base.for_controller(self)
def view_context
@_view_context ||= ActionView::Base.for_controller(self)
end
# Mostly abstracts the fact that calling render twice is a DoubleRenderError.
@ -55,7 +55,7 @@ module AbstractController
def render_to_body(options = {})
# TODO: Refactor so we can just use the normal template logic for this
if options[:_partial_object]
_action_view.render_partial(options)
view_context.render_partial(options)
else
_determine_template(options)
_render_template(options)
@ -77,7 +77,7 @@ module AbstractController
# _layout<ActionView::Template>:: The layout to wrap the template in (optional)
# _partial<TrueClass, FalseClass>:: Whether or not the template to be rendered is a partial
def _render_template(options)
_action_view.render_template(options[:_template], options[:_layout], options, options[:_partial])
view_context.render_template(options[:_template], options[:_layout], options, options[:_partial])
end
# The list of view paths for this controller. See ActionView::ViewPathSet for

View file

@ -72,7 +72,7 @@ module ActionController
# TODO: Remove this after we flip
def template
@template ||= _action_view
@template ||= view_context
end
def process_action(*)
@ -141,7 +141,7 @@ module ActionController
end
def view_paths
_action_view.view_paths
view_context.view_paths
end
end
end

View file

@ -85,7 +85,7 @@ module ActionController
register_renderer :update
def _render_update(proc, options)
generator = ActionView::Helpers::PrototypeHelper::JavaScriptGenerator.new(_action_view, &proc)
generator = ActionView::Helpers::PrototypeHelper::JavaScriptGenerator.new(view_context, &proc)
self.content_type = Mime::JS
self.response_body = generator.to_s
end

View file

@ -129,8 +129,7 @@ module ActionController #:nodoc:
end
def content_for_layout(controller)
# TODO: Remove this when new base is merged in
template = controller.respond_to?(:template) ? controller.template : controller._action_view
template = controller.view_context
template.layout && template.instance_variable_get('@cached_content_for_layout')
end
end

View file

@ -78,7 +78,7 @@ module ActionController
def assert_template(options = {}, message = nil)
validate_request!
hax = @controller._action_view.instance_variable_get(:@_rendered)
hax = @controller.view_context.instance_variable_get(:@_rendered)
case options
when NilClass, String