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

#determine_template, #find_layout, #render, #render_with_layout, #resolve_layout

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.



49
50
51
52
53
54
55
56
57
58
# File 'lib/action_view/renderer/streaming_template_renderer.rb', line 49

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