Sha256: 2af14204875cea1407ad7edccf73bd6e8b459dd19159126683bf182de0a18911

Contents?: true

Size: 1.4 KB

Versions: 27

Compression:

Stored size: 1.4 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) %>
  #   # => <turbo-frame id="tray_1" src="http://example.com/trays/1"></turbo-frame>
  #
  #   <%= turbo_frame_tag "tray", src: tray_path(tray), target: "_top" %>
  #   # => <turbo-frame id="tray" target="_top" src="http://example.com/trays/1"></turbo-frame>
  #
  #   <%= turbo_frame_tag "tray", target: "other_tray" %>
  #   # => <turbo-frame id="tray" target="other_tray"></turbo-frame>
  #
  #   <%= turbo_frame_tag "tray", src: tray_path(tray), loading: "lazy" %>
  #   # => <turbo-frame id="tray" src="http://example.com/trays/1" loading="lazy"></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)
    id = id.respond_to?(:to_key) ? dom_id(id) : id
    src = url_for(src) if src.present?

    tag.turbo_frame(**attributes.merge(id: id, src: src, target: target).compact, &block)
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
turbo-rails-1.0.1 app/helpers/turbo/frames_helper.rb
turbo-rails-1.0.0 app/helpers/turbo/frames_helper.rb
turbo-rails-0.9.1 app/helpers/turbo/frames_helper.rb
turbo-rails-0.9.0 app/helpers/turbo/frames_helper.rb
turbo-rails-0.8.3 app/helpers/turbo/frames_helper.rb
turbo-rails-0.8.2 app/helpers/turbo/frames_helper.rb
turbo-rails-0.8.1 app/helpers/turbo/frames_helper.rb
turbo-rails-0.8.0 app/helpers/turbo/frames_helper.rb
turbo-rails-0.7.15 app/helpers/turbo/frames_helper.rb
turbo-rails-0.7.14 app/helpers/turbo/frames_helper.rb
turbo-rails-0.7.13 app/helpers/turbo/frames_helper.rb
turbo-rails-0.7.12 app/helpers/turbo/frames_helper.rb
turbo-rails-0.7.11 app/helpers/turbo/frames_helper.rb
turbo-rails-0.7.10 app/helpers/turbo/frames_helper.rb
turbo-rails-0.7.9 app/helpers/turbo/frames_helper.rb
turbo-rails-0.7.8 app/helpers/turbo/frames_helper.rb
turbo-rails-0.7.7 app/helpers/turbo/frames_helper.rb
turbo-rails-0.7.6 app/helpers/turbo/frames_helper.rb
turbo-rails-0.7.5 app/helpers/turbo/frames_helper.rb
turbo-rails-0.7.4 app/helpers/turbo/frames_helper.rb