Class: Primrose::Components::Table

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

Constant Summary collapse

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

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