Method: Footnotes::Notes::AbstractNote#mount_table

Defined in:
lib/rails-footnotes/abstract_note.rb

#mount_table(array, options = {}) ⇒ Object

Gets a bidimensional array and create a table. The first array is used as label.



143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/rails-footnotes/abstract_note.rb', line 143

def mount_table(array, options = {})
  header = array.shift
  return '' if array.empty?

  header = header.collect{|i| escape(i.to_s.humanize) }
  rows = array.collect{|i| "<tr><td>#{i.join('</td><td>')}</td></tr>" }

  <<-TABLE
  <table #{hash_to_xml_attributes(options)}>
    <thead><tr><th>#{header.join('</th><th>')}</th></tr></thead>
    <tbody>#{rows.join}</tbody>
  </table>
  TABLE
end