Class: TableGo::Renderers::HtmlRenderer

Inherits:
Object
  • Object
show all
Includes:
RendererBase
Defined in:
lib/table_go/renderers/html_renderer.rb

Instance Method Summary collapse

Methods included from RendererBase

#apply_options

Instance Method Details

#render_templateObject



6
7
8
9
10
11
12
# File 'lib/table_go/renderers/html_renderer.rb', line 6

def render_template
  (:table, table_html) do
    concat((:caption, title)) if title
    concat(table_head)
    concat(table_body)
  end
end

#table_bodyObject



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/table_go/renderers/html_renderer.rb', line 24

def table_body
  (:tbody) do
    source_table.collection.each do |record|
       tr = (:tr, html_options_for_row(record)) do
        source_table.columns.each do |column|
          value = value_from_record_by_column(record, column)
          concat((:td, apply_formatter(record, column, value), html_options_for_cell(record, column, value)))
        end
       end
       concat(tr)
    end
  end
end

#table_footObject



38
39
40
41
42
43
# File 'lib/table_go/renderers/html_renderer.rb', line 38

def table_foot
  (:tfoot) do
    (:tr) do
    end
  end
end

#table_headObject



14
15
16
17
18
19
20
21
22
# File 'lib/table_go/renderers/html_renderer.rb', line 14

def table_head
  (:thead) do
    (:tr) do
      source_table.columns.each do |column|
        concat((:th, label_for_column(column), html_options_for_header(column)))
      end
    end
  end
end