module Turbo::StreamsHelper

def turbo_stream

requests by rendering the `messages/create.turbo_stream.erb` view template and transmitting the response
`MessagesController#create` will respond to `text/vnd.turbo-stream.html`
When a `app/views/messages/create.turbo_stream.erb` template exists, the

<% end %>
<%= render partial: "new_message", locals: { room: @room } %>
<%= turbo_stream.replace "new_message" do %>

<%= turbo_stream.append "messages", @message %>
<%# app/views/messages/create.turbo_stream.erb %>

end
end
format.html { redirect_to messages_url }
format.turbo_stream
respond_to do |format|
@message = Message.create!(params.require(:message).permit(:content))
def create

`text/html` and `text/vnd.turbo-stream.html` requests along with a `.turbo_stream.erb` action template:
style as `html` and `json` response formats. For example, consider a `MessagesController` that responds to both
When responding to HTTP requests, controllers can declare `turbo_stream` format response templates in that same

the template tags needed to send across the wire. This object is automatically yielded to turbo_stream.erb templates.
Returns a new Turbo::Streams::TagBuilder object that accepts stream actions and renders them as
def turbo_stream
  Turbo::Streams::TagBuilder.new(self)
end

def turbo_stream_from(*streamables, **attributes)

<%= turbo_stream_from("", nil) %> # => ArgumentError: streamables can't be blank
<%= turbo_stream_from("") %> # => ArgumentError: streamables can't be blank

Raises an +ArgumentError+ if all streamables are blank

<%= turbo_stream_from "room", channel: RoomChannel, data: {room_name: "room #1"} %>

It is also possible to pass additional parameters to the channel by passing them through `data` attributes:

<%= turbo_stream_from "room", channel: RoomChannel %>

or a class name):
Custom channel class name can be passed using :channel option (either as a String

entry.broadcast_append_to entry.account, :entries, target: "entries".
(when Current.account.id = 5). Updates to this stream can be sent like
The example above will process all turbo streams sent to a stream name like account:5:entries

New entries will be appended to this target

<%= turbo_stream_from Current.account, :entries %>
# app/views/entries/index.html.erb

fear of tampering, as it is signed using Turbo.signed_stream_verifier. Example:
Turbo::StreamsChannel. The stream name being generated is safe to embed in the HTML sent to a user without
Used in the view to create a subscription to a stream identified by the streamables running over the
def turbo_stream_from(*streamables, **attributes)
  raise ArgumentError, "streamables can't be blank" unless streamables.any?(&:present?)
  attributes[:channel] = attributes[:channel]&.to_s || "Turbo::StreamsChannel"
  attributes[:"signed-stream-name"] = Turbo::StreamsChannel.signed_stream_name(streamables)
  tag.turbo_cable_stream_source(**attributes)
end