Class: TableGo::Renderers::HtmlRenderer
- Inherits:
-
Object
- Object
- TableGo::Renderers::HtmlRenderer
- Includes:
- RendererBase
- Defined in:
- lib/table_go/renderers/html_renderer.rb
Instance Method Summary collapse
- #render_template ⇒ Object
- #table_body ⇒ Object
- #table_foot ⇒ Object
- #table_head ⇒ Object
- #table_rows ⇒ Object
Instance Method Details
#render_template ⇒ Object
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 content_tag(:table, table.table_html) do concat(content_tag(:caption, table.title)) if table.title concat(table_head) unless table.without_header concat(table_body) end end end |
#table_body ⇒ Object
28 29 30 31 32 |
# File 'lib/table_go/renderers/html_renderer.rb', line 28 def table_body content_tag(:tbody) do table_rows end end |
#table_foot ⇒ Object
46 47 48 49 50 51 |
# File 'lib/table_go/renderers/html_renderer.rb', line 46 def table_foot content_tag(:tfoot) do content_tag(:tr) do end end end |
#table_head ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/table_go/renderers/html_renderer.rb', line 18 def table_head content_tag(:thead) do content_tag(:tr) do table.columns.each do |column| concat(content_tag(:th, label_for_column(column), (column))) end end end end |
#table_rows ⇒ Object
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 = content_tag(:tr, (record)) do table.columns.each do |column| value = value_from_record_by_column(record, column) concat(content_tag(:td, apply_formatter(record, column, value), (record, column, value))) end end concat(tr) end end |