123456789_123456789_123456789_123456789_123456789_

Class: ActionView::AbstractRenderer

Do not use. This class is for internal use only.
Relationships & Source Files
Namespace Children
Modules:
Classes:
Extension / Inclusion / Inheritance Descendants
Subclasses:
Inherits: Object
Defined in: actionview/lib/action_view/renderer/abstract_renderer.rb

Overview

This class defines the interface for a renderer. Each class that subclasses AbstractRenderer is used by the base Renderer class to render a specific type of object.

The base Renderer class uses its #render method to delegate to the renderers. These currently consist of

PartialRenderer - Used for rendering partials
TemplateRenderer - Used for rendering other types of templates
StreamingTemplateRenderer - Used for streaming

Whenever the #render method is called on the base Renderer class, a new renderer object of the correct type is created, and the #render method on that new object is called in turn. This abstracts the set up and rendering into a separate classes for partials and templates.

Constant Summary

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(lookup_context) ⇒ AbstractRenderer

[ GitHub ]

  
# File 'actionview/lib/action_view/renderer/abstract_renderer.rb', line 24

def initialize(lookup_context)
  @lookup_context = lookup_context
end

Instance Attribute Details

#formats (readonly)

[ GitHub ]

  
# File 'actionview/lib/action_view/renderer/abstract_renderer.rb', line 22

delegate :template_exists?, :any_templates?, :formats, to: :@lookup_context

Instance Method Details

#any_templates?Boolean

[ GitHub ]

  
# File 'actionview/lib/action_view/renderer/abstract_renderer.rb', line 22

delegate :template_exists?, :any_templates?, :formats, to: :@lookup_context

#build_rendered_collection(templates, spacer) (private)

[ GitHub ]

  
# File 'actionview/lib/action_view/renderer/abstract_renderer.rb', line 182

def build_rendered_collection(templates, spacer)
  RenderedCollection.new templates, spacer
end

#build_rendered_template(content, template) (private)

[ GitHub ]

  
# File 'actionview/lib/action_view/renderer/abstract_renderer.rb', line 178

def build_rendered_template(content, template)
  RenderedTemplate.new content, template
end

#extract_details(options) (private)

[ GitHub ]

  
# File 'actionview/lib/action_view/renderer/abstract_renderer.rb', line 159

def extract_details(options) # :doc:
  details = nil
  LookupContext.registered_details.each do |key|
    value = options[key]

    if value
      (details ||= {})[key] = Array(value)
    end
  end
  details || NO_DETAILS
end

#prepend_formats(formats) (private)

[ GitHub ]

  
# File 'actionview/lib/action_view/renderer/abstract_renderer.rb', line 171

def prepend_formats(formats) # :doc:
  formats = Array(formats)
  return if formats.empty? || @lookup_context.html_fallback_for_js

  @lookup_context.formats = formats | @lookup_context.formats
end

#render

Raises:

  • (NotImplementedError)
[ GitHub ]

  
# File 'actionview/lib/action_view/renderer/abstract_renderer.rb', line 28

def render
  raise NotImplementedError
end

#template_exists?Boolean

[ GitHub ]

  
# File 'actionview/lib/action_view/renderer/abstract_renderer.rb', line 22

delegate :template_exists?, :any_templates?, :formats, to: :@lookup_context