Class: Primrose::Components::Table

Inherits:
Rose
  • Object
show all
Defined in:
lib/primrose/components/table.rb

Constant Summary collapse

TEMPLATE =
<<~ERB
  <table>
    <thead>
      <tr>
        <% @headers.each do |header| %>
          <th><%= header %></th>
        <% end %>
      </tr>
    </thead>
    <tbody>
      <% @rows.each do |row| %>
        <tr>
          <% row.each do |cell| %>
            <td><%= cell %></td>
          <% end %>
        </tr>
      <% end %>
    </tbody>
  </table>
ERB

Instance Attribute Summary

Attributes inherited from Rose

#children, #event_handlers, #state

Instance Method Summary collapse

Methods inherited from Rose

#add_child, #get_binding, #handle_error, #lifecycle, #on, #render_children, #trigger

Constructor Details

#initialize(headers, rows) ⇒ Table

Returns a new instance of Table.



25
26
27
28
# File 'lib/primrose/components/table.rb', line 25

def initialize(headers, rows)
  @headers = headers
  @rows = rows
end

Instance Method Details

#renderObject



30
31
32
# File 'lib/primrose/components/table.rb', line 30

def render
  Prim.render(TEMPLATE, self)
end