Class: RenderTable::Table
Instance Attribute Summary
Attributes inherited from Base
#header, #html, #options, #override, #records, #table_class, #table_id, #timestamps
Instance Method Summary collapse
Methods inherited from Base
#context, #initialize, render, #render, #rows
Constructor Details
This class inherits a constructor from RenderTable::Base
Instance Method Details
#template ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/render_table/table.rb', line 2 def template <<-HTML <table id="<%= table.table_id %>" class="<%= table.table_class %>"> <thead> <tr> <% table.header.each do |header| %> <th><%= header.to_s %></th> <% end %> <% if table.timestamps %> <th>Date Created</th> <th>Last Updated</th> <% end %> <% if table.options %> <th>Options</th> <% end %> </tr> </thead> <tbody> <% table.rows.each do |row| %> <tr id="<%= row.id %>" class="<%= row.class %>"> <% row.cells.each do |cell| %> <td id="<%= cell.id %>" class="<%= cell.class %>"> <%= cell.value %> </td> <% end %> <% if table.timestamps %> <td><%= row.record.created_at.strftime("%b %e, %Y - %l:%M %p %Z") %></td> <td><%= row.record.updated_at.strftime("%b %e, %Y - %l:%M %p %Z") %></td> <% end %> <% if table.options %> <td><%= options_cell(row.record, row.row_index) %></td> <% end %> </tr> <% end %> </tbody> </table> HTML end |