method
delayed_render

v7.1.3.2 -
Show latest stable
-
0 notes -
Class: StreamingTemplateRenderer
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0
- 3.0.9
- 3.1.0 (0)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (0)
- 4.1.8 (0)
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (0)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- What's this?
delayed_render(buffer, template, layout, view, locals)
private
Hide source
# File actionview/lib/action_view/renderer/streaming_template_renderer.rb, line 57 def delayed_render(buffer, template, layout, view, locals) # Wrap the given buffer in the StreamingBuffer and pass it to the # underlying template handler. Now, every time something is concatenated # to the buffer, it is not appended to an array, but streamed straight # to the client. output = ActionView::StreamingBuffer.new(buffer) yielder = lambda { |*name| view._layout_for(*name) } ActiveSupport::Notifications.instrument( "render_template.action_view", identifier: template.identifier, layout: layout && layout.virtual_path, locals: locals ) do outer_config = I18n.config fiber = Fiber.new do I18n.config = outer_config if layout layout.render(view, locals, output, &yielder) else # If you don't have a layout, just render the thing # and concatenate the final result. This is the same # as a layout with just <%= yield %> output.safe_concat view._layout_for end end # Set the view flow to support streaming. It will be aware # when to stop rendering the layout because it needs to search # something in the template and vice-versa. view.view_flow = StreamingFlow.new(view, fiber) # Yo! Start the fiber! fiber.resume # If the fiber is still alive, it means we need something # from the template, so start rendering it. If not, it means # the layout exited without requiring anything from the template. if fiber.alive? content = template.render(view, locals, &yielder) # Once rendering the template is done, sets its content in the :layout key. view.view_flow.set(:layout, content) # In case the layout continues yielding, we need to resume # the fiber until all yields are handled. fiber.resume while fiber.alive? end end end