Class: DiningTable::Presenters::HTMLPresenter
- Inherits:
-
Presenter
- Object
- Presenter
- DiningTable::Presenters::HTMLPresenter
show all
- Defined in:
- lib/dining-table/presenters/html_presenter.rb
Instance Attribute Summary collapse
Attributes inherited from Presenter
#options, #table, #view_context
Instance Method Summary
collapse
Methods inherited from Presenter
#connect_to, #type?
Constructor Details
#initialize(options = {}) ⇒ HTMLPresenter
Returns a new instance of HTMLPresenter.
12
13
14
15
16
17
|
# File 'lib/dining-table/presenters/html_presenter.rb', line 12
def initialize( options = {} )
super
self.base_tags_configuration = HTMLPresenterConfiguration::TagsConfiguration.from_hash( default_options )
base_tags_configuration.merge_hash( options )
self.output = ''
end
|
Instance Attribute Details
Returns the value of attribute base_tags_configuration.
7
8
9
|
# File 'lib/dining-table/presenters/html_presenter.rb', line 7
def base_tags_configuration
@base_tags_configuration
end
|
#output ⇒ Object
89
90
91
|
# File 'lib/dining-table/presenters/html_presenter.rb', line 89
def output
@output.respond_to?(:html_safe) ? @output.html_safe : @output
end
|
#row_config_block ⇒ Object
Returns the value of attribute row_config_block.
7
8
9
|
# File 'lib/dining-table/presenters/html_presenter.rb', line 7
def row_config_block
@row_config_block
end
|
#table_config_block ⇒ Object
Returns the value of attribute table_config_block.
7
8
9
|
# File 'lib/dining-table/presenters/html_presenter.rb', line 7
def table_config_block
@table_config_block
end
|
Returns the value of attribute table_tags_configuration.
7
8
9
|
# File 'lib/dining-table/presenters/html_presenter.rb', line 7
def table_tags_configuration
@table_tags_configuration
end
|
Returns the value of attribute tags_configuration.
7
8
9
|
# File 'lib/dining-table/presenters/html_presenter.rb', line 7
def tags_configuration
@tags_configuration
end
|
Instance Method Details
#end_body ⇒ Object
42
43
44
|
# File 'lib/dining-table/presenters/html_presenter.rb', line 42
def end_body
add_tag(:end, :tbody)
end
|
#end_table ⇒ Object
31
32
33
34
35
36
|
# File 'lib/dining-table/presenters/html_presenter.rb', line 31
def end_table
add_tag(:end, :table)
if options[:wrap]
add_tag(:end, wrap_tag )
end
end
|
#identifier ⇒ Object
19
20
21
|
# File 'lib/dining-table/presenters/html_presenter.rb', line 19
def identifier
:html
end
|
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/dining-table/presenters/html_presenter.rb', line 72
def
set_up_row_configuration( :footer, nil )
= columns.each.map(&:footer)
if .map { |s| blank?(s) }.uniq != [ true ]
add_tag(:start, :tfoot, tag_options(:tfoot))
add_tag(:start, :tr, row_options)
columns.each_with_index do |column, index|
value = [index]
configuration = cell_configuration( tags_configuration, column, :footer, nil )
( value, configuration )
end
add_tag(:end, :tr)
add_tag(:end, :tfoot)
end
end
|
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/dining-table/presenters/html_presenter.rb', line 58
def
set_up_row_configuration( :header, nil )
add_tag(:start, :thead, tag_options(:thead))
add_tag(:start, :tr, row_options)
columns.each do |column|
value = column.
configuration = cell_configuration( tags_configuration, column, :header, nil )
( value, configuration )
end
add_tag(:end, :tr)
add_tag(:end, :thead)
end
|
#render_row(object) ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/dining-table/presenters/html_presenter.rb', line 46
def render_row( object )
set_up_row_configuration( table.index, object )
add_tag(:start, :tr, row_options)
columns.each do |column|
value = column.value( object )
configuration = cell_configuration( tags_configuration, column, table.index, object )
render_cell( value, configuration )
end
add_tag(:end, :tr)
end
|
#row_config(&block) ⇒ Object
97
98
99
|
# File 'lib/dining-table/presenters/html_presenter.rb', line 97
def row_config(&block)
self.row_config_block = block
end
|
#start_body ⇒ Object
38
39
40
|
# File 'lib/dining-table/presenters/html_presenter.rb', line 38
def start_body
add_tag(:start, :tbody, tag_options(:tbody))
end
|
#start_table ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/dining-table/presenters/html_presenter.rb', line 23
def start_table
set_up_configuration
if options[:wrap]
add_tag(:start, wrap_tag, wrap_options )
end
add_tag(:start, :table, table_options )
end
|
#table_config(&block) ⇒ Object
93
94
95
|
# File 'lib/dining-table/presenters/html_presenter.rb', line 93
def table_config(&block)
self.table_config_block = block
end
|