Sha256: 3e9ec44c2ddb5faf41eb8ea5a1734c3b6b1181123faea29dc3a3b6c1163aab4d

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

module Turbo::FramesHelper
  # Returns a frame tag that can either be used simply to encapsulate frame content or as a lazy-loading container that starts empty but
  # fetches the URL supplied in the +src+ attribute.
  #
  # === Examples
  #
  #   <%= turbo_frame_tag "tray", src: tray_path(tray) %>
  #   # => <turbo-frame id="tray" src="http://example.com/trays/1"></turbo-frame>
  #
  #   <%= turbo_frame_tag "tray", src: tray_path(tray), links_target: "top" %>
  #   # => <turbo-frame id="tray" links-target="top" src="http://example.com/trays/1"></turbo-frame>
  #
  #   <%= turbo_frame_tag "tray", links_target: "other_tray" %>
  #   # => <turbo-frame id="tray" links-target="other_tray"></turbo-frame>
  #
  #   <%= turbo_frame_tag "tray" do %>
  #     <div>My tray frame!</div>
  #   <% end %>
  #   # => <turbo-frame id="tray"><div>My tray frame!</div></turbo-frame>
  def turbo_frame_tag(id, src: nil, target: nil, **attributes, &block)
    tag.turbo_frame(**attributes.merge(id: id, src: src, target: target).compact, &block)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
turbo-rails-0.5.1 app/helpers/turbo/frames_helper.rb