Class: WikiCloth::WikiBuffer::Table
Instance Method Summary
collapse
#add_char, #add_word, #buffer_type, #buffers, #check_globals, #data, #debug, #eof, #get_param, #in_template?, #params, #run_globals?, #skip_html?, #skip_links?
Constructor Details
#initialize(data = "", options = {}) ⇒ Table
Returns a new instance of Table.
5
6
7
8
9
10
11
12
|
# File 'lib/wikicloth/wiki_buffer/table.rb', line 5
def initialize(data="",options={})
super(data,options)
self.buffer_type = "table"
@start_table = true
@start_row = false
@start_caption = false
@in_quotes = false
end
|
Instance Method Details
23
24
25
|
# File 'lib/wikicloth/wiki_buffer/table.rb', line 23
def rows
@rows ||= [ [] ]
end
|
#table_caption ⇒ Object
14
15
16
17
|
# File 'lib/wikicloth/wiki_buffer/table.rb', line 14
def table_caption
@caption ||= ""
return @caption.kind_of?(Hash) ? @caption[:value] : @caption
end
|
#table_caption_attributes ⇒ Object
19
20
21
|
# File 'lib/wikicloth/wiki_buffer/table.rb', line 19
def table_caption_attributes
@caption.kind_of?(Hash) ? @caption[:style] : ""
end
|
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/wikicloth/wiki_buffer/table.rb', line 27
def to_html
row_count = 0
ret = "<table" + (params[0].blank? ? "" : " #{params[0].strip}") + ">"
ret += "<caption" + (self.table_caption_attributes.blank? ? "" : " #{table_caption_attributes.strip}") +
">#{table_caption.strip}</caption>" unless self.table_caption.blank?
for row in rows
row_count += 1
unless row.empty?
ret += "<tr" + (params[row_count].nil? || params[row_count].blank? ? "" : " #{params[row_count].strip}") + ">"
for cell in row
cell_attributes = cell[:style].blank? ? "" : parse_attributes(cell[:style].strip).collect { |k,v| "#{k}=\"#{v}\"" }.join(" ")
cell_attributes = cell_attributes.blank? ? "" : " #{cell_attributes}"
ret += "<#{cell[:type]}#{cell_attributes}>\n#{cell[:value].strip}\n</#{cell[:type]}>"
end
ret += "</tr>"
end
end
ret += "</table>"
end
|