Class: TableGo::Renderers::HtmlRenderer

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

Instance Method Summary collapse

Instance Method Details

#render_templateObject



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

def render_template
  if table.render_rows_only
    table_rows
  else
    (:table, table.table_html) do
      concat((:caption, table.title)) if table.title
      concat(table_head) unless table.without_header
      concat(table_body)
    end
  end
end

#table_bodyObject



28
29
30
31
32
# File 'lib/table_go/renderers/html_renderer.rb', line 28

def table_body
  (:tbody) do
    table_rows
  end
end

#table_footObject



46
47
48
49
50
51
# File 'lib/table_go/renderers/html_renderer.rb', line 46

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

#table_headObject



18
19
20
21
22
23
24
25
26
# File 'lib/table_go/renderers/html_renderer.rb', line 18

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

#table_rowsObject



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/table_go/renderers/html_renderer.rb', line 34

def table_rows
  table.collection.each do |record|
     tr = (:tr, html_options_for_row(record)) do
      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