Sha256: 14c8493ce143e8bdef1b1a7baff49fa07cae91e5b0df4388dc1f5e754e4e88ee

Contents?: true

Size: 623 Bytes

Versions: 3

Compression:

Stored size: 623 Bytes

Contents

# frozen_string_literal: true

module Katalyst
  module Tables
    # View Helper for generating HTML tables. Include in your ApplicationHelper, or similar.
    module Frontend
      def table_with(collection:, component: nil, **options, &block)
        component ||= default_table_component_class
        render(component.new(collection: collection, **options), &block)
      end

      private

      def default_table_component_class
        component = controller.try(:default_table_component) || TableComponent
        component.respond_to?(:constantize) ? component.constantize : component
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
katalyst-tables-2.6.0.beta app/helpers/katalyst/tables/frontend.rb
katalyst-tables-2.5.0 app/helpers/katalyst/tables/frontend.rb
katalyst-tables-2.4.0 app/helpers/katalyst/tables/frontend.rb