Class: TableCloth::Presenters::Default
Instance Attribute Summary
#objects, #table, #view_context
Instance Method Summary
collapse
#column_names, #columns, #initialize, #row_values, #rows, #wrapper_tag
Instance Method Details
36
37
38
39
40
41
42
|
# File 'lib/table_cloth/presenters/default.rb', line 36
def
wrapper_tag :thead do
wrapper_tag :tr do
v.raw column_names.inject("") {|tags, name| tags + wrapper_tag(:th, name) }
end
end
end
|
#render_row(object) ⇒ Object
16
17
18
19
20
|
# File 'lib/table_cloth/presenters/default.rb', line 16
def render_row(object)
wrapper_tag :tr do
v.raw columns.inject("") {|tds, column| tds + render_td(column, object) }
end
end
|
#render_rows ⇒ Object
10
11
12
13
14
|
# File 'lib/table_cloth/presenters/default.rb', line 10
def render_rows
wrapper_tag :tbody do
v.raw objects.inject("") {|r, object| r + render_row(object) }
end
end
|
#render_table ⇒ Object
4
5
6
7
8
|
# File 'lib/table_cloth/presenters/default.rb', line 4
def render_table
wrapper_tag :table do
+ render_rows
end
end
|
#render_td(column, object) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/table_cloth/presenters/default.rb', line 22
def render_td(column, object)
td_options = column.options[:td_options] || {}
value = column.value(object, view_context, table)
if value.is_a?(Array)
options = value.pop
value = value.shift
td_options.update(options)
end
wrapper_tag(:td, value, td_options)
end
|