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 Attribute Summary collapse

Instance Method Summary collapse

Methods included from ViewPaths

#_prefixes, all_view_paths, #append_view_path, #details_for_lookup, get_view_paths, #lookup_context, #prepend_view_path, set_view_paths

Instance Attribute Details

#rendered_formatObject (readonly)

Returns the value of attribute rendered_format.



29
30
31
# File 'lib/action_view/rendering.rb', line 29

def rendered_format
  @rendered_format
end

Instance Method Details

#initializeObject



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

def initialize
  @rendered_format = nil
  super
end

#processObject

Override process to set up I18n proxy.



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

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



101
102
103
104
# File 'lib/action_view/rendering.rb', line 101

def render_to_body(options = {})
  _process_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.



91
92
93
# File 'lib/action_view/rendering.rb', line 91

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

#view_context_classObject



77
78
79
# File 'lib/action_view/rendering.rb', line 77

def view_context_class
  self.class.view_context_class
end

#view_rendererObject

Returns an object that is able to render templates.



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

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