Sha256: 769b8e0240658a2479a3766e776b94ec88ba45a17285b93c7b7382840e8e5b09

Contents?: true

Size: 799 Bytes

Versions: 5

Compression:

Stored size: 799 Bytes

Contents

# frozen_string_literal: true

module PagesCore
  module Admin
    module ContentTabsHelper
      def content_tab(name, options = {}, &block)
        @content_tabs ||= []
        return unless block_given?

        tab = {
          name: name.to_s.humanize,
          key: options[:key] || name.to_s.underscore.gsub(/\s+/, "_"),
          options: options,
          content: capture(&block)
        }
        @content_tabs << tab
        content_tab_tag(tab[:key], tab[:content])
      end

      private

      def content_tab_tag(key, content)
        tag.div(content,
                class: "content-tab",
                id: "content-tab-#{key}",
                role: "tabpanel",
                data: { tab: key,
                        "main-target" => "tab" })
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pages_core-3.12.4 app/helpers/pages_core/admin/content_tabs_helper.rb
pages_core-3.12.3 app/helpers/pages_core/admin/content_tabs_helper.rb
pages_core-3.12.2 app/helpers/pages_core/admin/content_tabs_helper.rb
pages_core-3.12.1 app/helpers/pages_core/admin/content_tabs_helper.rb
pages_core-3.12.0 app/helpers/pages_core/admin/content_tabs_helper.rb