module Phlex::Table
def self.included(child)
def self.included(child) child.extend ClassMethods child.alias_method :head, :thead child.alias_method :body, :tbody child.alias_method :foot, :tfoot child.alias_method :row, :tr child.alias_method :header, :th child.alias_method :cell, :td child.alias_method :head_row, :row child.alias_method :body_row, :row child.alias_method :foot_row, :row child.alias_method :head_header, :header child.alias_method :foot_header, :header child.alias_method :head_cell, :cell child.alias_method :body_cell, :cell child.alias_method :foot_cell, :cell end
def body_template
def body_template body { yield_items } end
def collection_template(&block)
def collection_template(&block) table do head_template body_template(&block) foot_template end end
def foot_template
def foot_template end
def head_template
def head_template if self.class.properties.any? { |p| p[:header] } head do head_row do self.class.properties.each do |property| case property[:header] when Proc instance_exec(&property[:header]) when Symbol send(property[:header]) end end end end end end
def item_template
def item_template row_template end
def properties
def properties self.class.properties end
def row_template
def row_template body_row do self.class.properties.each do |property| body_cell(**property[:attributes]) do instance_exec(@item, &property[:body]) end end end end