Module: Turbo::Streams::TurboStreamsTagBuilder

Defined in:
app/controllers/turbo/streams/turbo_streams_tag_builder.rb

Overview

Most turbo streams are rendered either asynchronously via Turbo::Broadcastable/Turbo::StreamsChannel or rendered in templates with the turbo_stream.erb extension. But it’s also possible to render updates inline in controllers, like so:

def destroy
  @user.destroy!

  respond_to do |format|
    format.turbo_stream { render turbo_stream: turbo_stream.remove(@user) }
    format.html         { redirect_to users_url, notice: "User removed" }
  end
end

This module adds that turbo_stream tag-builder object to all controllers. It’s an instance of Turbo::Streams::TagBuilder instantiated with the current view_context.