views: add table builder abstraction.
This commit is contained in:
21
app/views/table_builder/_table.html.erb
Normal file
21
app/views/table_builder/_table.html.erb
Normal file
@@ -0,0 +1,21 @@
|
||||
<%= tag.table table.html_attributes do %>
|
||||
<thead>
|
||||
<tr>
|
||||
<% table.columns.each do |column| %>
|
||||
<th><%= column.name %></th>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% table.items.each do |item| %>
|
||||
<%= tag.tr table.row_attributes(item) do %>
|
||||
<% table.columns.each do |column| %>
|
||||
<%= tag.td column.html_attributes do %>
|
||||
<%= column.value(item) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
<% end %>
|
||||
Reference in New Issue
Block a user