Sha256: 0c9736fca7f6f4086a6fa661b814a466b2e124ce76ae877861ef23e10743f6d0

Contents?: true

Size: 899 Bytes

Versions: 1

Compression:

Stored size: 899 Bytes

Contents

module Trestle
  module TurboFrameHelper
    def index_turbo_frame(options={}, &block)
      defaults = {
        id: "index",
        data: {
          controller: "reloadable",
          turbo_action: "advance"
        }
      }

      content_tag("turbo-frame", defaults.merge(options), &block)
    end

    def resource_turbo_frame(instance, options={}, &block)
      defaults = {
        id: dom_id(instance),
        target: ("_top" unless modal_request?),
        data: {
          controller: resource_turbo_frame_controllers.join(" ").presence
        }
      }

      content_tag("turbo-frame", defaults.merge(options), &block)
    end

    def resource_turbo_frame_controllers
      controllers = []
      controllers << "modal-frame" if modal_request?
      controllers << "deprecated--init" if modal_request? || request.post? || turbo_frame_request?
      controllers
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
trestle-0.10.0.pre app/helpers/trestle/turbo_frame_helper.rb