Class: ActionView::StreamingTemplateRenderer

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

Overview

TODO

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

  • Integrate exceptions with exceptron

  • 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(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.



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

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

  locals ||= {}
  layout   = layout_name && find_layout(layout_name, locals.keys)

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