class TagBuilder

Ruby on Rails 1.4.0

Since v1.3.3 Last seen in v2.0.23

Available in: v1.3.3 v1.4.0 v1.5.0 v2.0.23

This tag builder is used both for inline controller turbo actions (see Turbo::Streams::TurboStreamsTagBuilder) and for turbo stream templates. This object plays together with any normal Ruby you’d run in an ERB template, so you can iterate, like:

<% # app/views/postings/destroy.turbo_stream.erb %>
<% @postings.each do |posting| %>
  <%= turbo_stream.remove posting %>
<% end %>

Or string several separate updates together:

<% # app/views/entries/_entry.turbo_stream.erb %>
<%= turbo_stream.remove entry %>

<%= turbo_stream.append "entries" do %>
  <% # format is automatically switched, such that _entry.html.erb partial is rendered, not _entry.turbo_stream.erb %>
  <%= render partial: "entries/entry", locals: { entry: entry } %>
<% end %>

Or you can render the HTML that should be part of the update inline:

<% # app/views/topics/merges/_merge.turbo_stream.erb %>
<%= turbo_stream.append dom_id(topic_merge) do %>
  <%= link_to topic_merge.topic.name, topic_path(topic_merge.topic) %>
<% end %>

Inherits from

Object

Includes

Methods (defined here)

Private methods

(2) Implementation detail — not part of the public API.

Methods (inherited)

From Turbo::Streams::ActionHelper (1)

Type at least 2 characters to search.

↑↓ navigate · open · esc close