Class: HtmlTables::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/html_tables/renderer.rb

Instance Method Summary collapse

Constructor Details

#initialize(helper, table, collection, options = {}) ⇒ Renderer

Returns a new instance of Renderer.



3
4
5
6
7
8
9
# File 'lib/html_tables/renderer.rb', line 3

def initialize(helper, table, collection, options = {})
  @helper = helper
  @t = table
  @collection = collection
  @options = options
  @config = HtmlTables::Configuration.instance
end

Instance Method Details

#to_htmlObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/html_tables/renderer.rb', line 11

def to_html
  cls = config.default_table_classes.dup
  cls << 'table-condensed' if options[:condensed]
  cls << options[:class] if options[:class]
  table_html_options = { class: cls }
  table_html_options.merge!(options[:html]) { |_, v1, v2| [v1, v2].flatten } if options[:html]

  (:table, table_html_options) do
    content = ''.html_safe
    content << caption << colgroup << thead << tfoot << tbody
  end
end