Sha256: 4b154aa00e05f6728876c0c49949466aba6a598a103626096eafd327ff459e0f

Contents?: true

Size: 1.19 KB

Versions: 3

Compression:

Stored size: 1.19 KB

Contents

module TableGo
  module Renderers
    class HtmlRenderer
      include RendererBase

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

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

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
table_go-0.2.2 lib/table_go/renderers/html_renderer.rb
table_go-0.2.1 lib/table_go/renderers/html_renderer.rb
table_go-0.2.0 lib/table_go/renderers/html_renderer.rb