Class: CafeCar::TableBuilder

Inherits:
CafeCar::Table::Builder show all
Defined in:
lib/cafe_car/table_builder.rb

Instance Attribute Summary

Attributes inherited from CafeCar::Table::Builder

#ui

Instance Method Summary collapse

Methods inherited from CafeCar::Table::Builder

#cell, #has?, #html_safe?, #initialize, #logo, #model_name, #remaining, #remaining_attributes, #shown, #shown!, #timestamp_attribute, #timestamps, #title, #to_s, #~@

Methods included from OptionHelpers

#assign_option!, #assign_options!, #get_options

Methods included from ProcHelpers

#call_procs!, #clone_or_call!

Constructor Details

This class inherits a constructor from CafeCar::Table::Builder

Instance Method Details

#to_htmlObject



3
4
5
6
7
8
9
10
11
# File 'lib/cafe_car/table_builder.rb', line 3

def to_html
  head    = Table::HeadBuilder.new(@template, **@options, &@block).tap(&:to_s)
  columns = head.fields.map(&:width).join(" ")
  @template.ui.Table style: "grid-template-columns: #{columns}" do |table|
    ~head
    ~Table::BodyBuilder.new(@template, **@options, &@block)
    ~Table::FootBuilder.new(@template, **@options, &@block)
  end
end