module SuperTable::ActionView

Public Instance Methods

super_table(table, options={}, &block) click to toggle source
# File lib/super_table/action_view.rb, line 6
def super_table(table, options={}, &block)

  options[:hover] = options.fetch(:hover, true)
  is_hover = options.delete(:hover)
  table_responsive = options.delete(:responsive)
  table_size = options.delete(:size).to_s

  classes = ['table']
  classes << options[:class] if options[:class]
  classes.push("table-hover") if is_hover && table.collection.present?
  classes.push("table-sm") if table_size == 'sm'

  options[:class] = classes.join(" ")

  case table_responsive.to_s
  when 'sm', 'md', 'lg', 'xl'
    content_tag(:div, class: "table-responsive-#{table_responsive}") do
      render_table(table, options, &block)
    end
  else
    render_table(table, options, &block)
  end
end

Protected Instance Methods

render_table(table, options={}) { |builder| ... } click to toggle source
# File lib/super_table/action_view.rb, line 32
def render_table(table, options={}, &block)
  content_tag(:table, options) do
    yield Builder.new(table, self) if block_given?
  end
end