Class: ActionView::StreamingTemplateRenderer

Inherits:
TemplateRenderer show all
Defined in:
actionview/lib/action_view/renderer/streaming_template_renderer.rb

Overview

TODO

  • Support streaming from child templates, partials and so on.

  • Rack::Cache needs to support streaming bodies

Defined Under Namespace

Classes: Body

Instance Method Summary collapse

Methods inherited from TemplateRenderer

#render

Methods inherited from AbstractRenderer

#initialize, #render

Constructor Details

This class inherits a constructor from ActionView::AbstractRenderer

Instance Method Details

#render_template(view, template, layout_name = nil, locals = {}) ⇒ Object

For streaming, instead of rendering a given a template, we return a Body object that responds to each. This object is initialized with a block that knows how to render the template.



45
46
47
48
49
50
51
52
53
54
# File 'actionview/lib/action_view/renderer/streaming_template_renderer.rb', line 45

def render_template(view, template, layout_name = nil, locals = {}) #:nodoc:
  return [super.body] unless layout_name && template.supports_streaming?

  locals ||= {}
  layout   = layout_name && find_layout(layout_name, locals.keys, [formats.first])

  Body.new do |buffer|
    delayed_render(buffer, template, layout, view, locals)
  end
end