Class: ActionView::StreamingTemplateRenderer

Inherits:
TemplateRenderer
  • Object
show all
Defined in:
ext/actionview/streaming_template_renderer.rb

Instance Method Summary collapse

Instance Method Details

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

:nodoc:



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'ext/actionview/streaming_template_renderer.rb', line 4

def render_template(view, template, layout_name = nil, locals = {}) #:nodoc:
  template_supports_streaming = (layout_name && template.supports_streaming?) || template.handler == TurboStreamer::Handler
  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|
    if template.handler == TurboStreamer::Handler
      delayed_render_json(buffer, template, layout, view, locals)
    else
      delayed_render(buffer, template, layout, view, locals)
    end
  end
end