Class: Tablette::Table
Instance Attribute Summary
Attributes inherited from Element
Instance Method Summary collapse
- #footer(&block) ⇒ Object
- #header(&block) ⇒ Object
-
#initialize(*args, &block) ⇒ Table
constructor
A new instance of Table.
- #to_html(*args) ⇒ Object
Methods inherited from Element
#element_to_html, #method_missing, #respond_to_missing?
Constructor Details
#initialize(*args, &block) ⇒ Table
Returns a new instance of Table.
14 15 16 17 18 19 20 21 |
# File 'lib/tablette/table.rb', line 14 def initialize(*args, &block) @renderer = HTMLRenderer.new @helper = nil @header_builder = nil @cached_autoheader = nil super end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Tablette::Element
Instance Method Details
#footer(&block) ⇒ Object
29 30 31 32 33 |
# File 'lib/tablette/table.rb', line 29 def (&block) do column(html_options: { colspan: 'auto'}, &block) end end |
#header(&block) ⇒ Object
23 24 25 26 27 |
# File 'lib/tablette/table.rb', line 23 def header(&block) header! do column(html_options: { colspan: 'auto'}, &block) end end |
#to_html(*args) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/tablette/table.rb', line 35 def to_html(*args) columns = 0 all_sections = [ self.header!, build_autoheader(args), self.body, self. ].flatten! all_sections.each do |section| section_columns = section.columns_for_section args columns = section_columns if section_columns > columns end all_sections.each do |section| section.update_auto_colspan! columns, args end @sections_to_render = all_sections begin @renderer.to_html(super) ensure @sections_to_render = nil end end |