25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/munger/render/html.rb', line 25
def render
x = Builder::XmlMarkup.new
x.table(:class => @classes[:table]) do
x.thead do
x.tr do
@report.columns.each do |column|
x.th(:class => 'columnTitle') { x << @report.column_title(column) }
end
end
end
x.tbody do
@report.process_data.each do |row|
classes = []
classes << row[:meta][:row_styles]
classes << 'group' + row[:meta][:group].to_s if row[:meta][:group]
classes << cycle('even', 'odd')
classes.compact!
if row[:meta][:group_header]
classes << 'groupHeader' + row[:meta][:group_header].to_s
end
row_attrib = {}
row_attrib = {:class => classes.join(' ')} if classes.size > 0
if row[:meta][:group_header]
x.thead do
x.tr(row_attrib) do
= @report.column_title(row[:meta][:group_name]) + ' : ' + row[:meta][:group_value].to_s
x.th(:colspan => @report.columns.size) { x << }
end
end
else
x.tr(row_attrib) do
@report.columns.each do |column|
cell_attrib = {}
if cst = row[:meta][:cell_styles]
cst = Item.ensure(cst)
if cell_styles = cst[column]
cell_attrib = {:class => cell_styles.join(' ')}
end
end
x.td(cell_attrib) do
formatter,*args = *@report.column_formatter(column)
col_data = row[:data] if formatter && col_data[column]
formatted = if formatter.class == Proc
data = col_data.respond_to?(:data) ? col_data.data : col_data
formatter.call(data)
elsif col_data[column].respond_to? formatter
col_data[column].send(formatter, *args)
elsif
col_data[column].to_s
end
else
formatted = col_data[column].to_s
end
x << formatted.to_s
end
end end end
end
end
end
end
|