Class: Primrose::Components::Table
- 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
-
#initialize(headers, rows) ⇒ Table
constructor
A new instance of Table.
- #render ⇒ Object
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
#render ⇒ Object
30 31 32 |
# File 'lib/primrose/components/table.rb', line 30 def render Prim.render(TEMPLATE, self) end |