Module: ActionView::Rendering

Extended by:
ActiveSupport::Concern
Includes:
ViewPaths
Included in:
Layouts
Defined in:
lib/action_view/rendering.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Methods included from ViewPaths

#_prefixes, #append_view_path, #details_for_lookup, #lookup_context, #prepend_view_path

Instance Method Details

#initializeObject



32
33
34
35
# File 'lib/action_view/rendering.rb', line 32

def initialize
  @_rendered_format = nil
  super
end

#processObject

Override process to set up I18n proxy.



38
39
40
41
42
43
# File 'lib/action_view/rendering.rb', line 38

def process(...) # :nodoc:
  old_config, I18n.config = I18n.config, I18nProxy.new(I18n.config, lookup_context)
  super
ensure
  I18n.config = old_config
end

#render_to_body(options = {}) ⇒ Object



119
120
121
122
123
# File 'lib/action_view/rendering.rb', line 119

def render_to_body(options = {})
  _process_options(options)
  _process_render_template_options(options)
  _render_template(options)
end

#view_contextObject

An instance of a view class. The default view class is ActionView::Base.

The view class must have the following methods:

  • View.new(lookup_context, assigns, controller) — Create a new ActionView instance for a controller and we can also pass the arguments.

  • View#render(option) — Returns String with the rendered template.

Override this method in a module to change the default behavior.



109
110
111
# File 'lib/action_view/rendering.rb', line 109

def view_context
  view_context_class.new(lookup_context, view_assigns, self)
end

#view_context_classObject



95
96
97
# File 'lib/action_view/rendering.rb', line 95

def view_context_class
  self.class.view_context_class
end

#view_rendererObject

Returns an object that is able to render templates.



114
115
116
117
# File 'lib/action_view/rendering.rb', line 114

def view_renderer # :nodoc:
  # Lifespan: Per controller
  @_view_renderer ||= ActionView::Renderer.new(lookup_context)
end