Class: Grapple::Components::HtmlBody
- Inherits:
-
HtmlComponent
- Object
- BaseComponent
- HtmlComponent
- Grapple::Components::HtmlBody
- Defined in:
- lib/grapple/components/html_body.rb
Instance Attribute Summary
Attributes inherited from BaseComponent
#builder, #columns, #params, #records, #template
Instance Method Summary collapse
Methods inherited from BaseComponent
Constructor Details
This class inherits a constructor from Grapple::Components::BaseComponent
Instance Method Details
#render(*options, &block) ⇒ Object
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 40 |
# File 'lib/grapple/components/html_body.rb', line 15 def render(*, &block) = [0] || {} wrap_row = if [:tr].nil? self.tr elsif [:tr] === false false else [:tr] end args = {} if records.empty? && ![:no_rows_html].nil? html = ["<tr><td colspan=\"#{columns.length}\">#{[:no_rows_html]}</td></tr>"] else html = records.collect do |data| if wrap_row args = wrap_row.call(template) if wrap_row.is_a?(Proc) builder.row(capture_block { block.call(data) }, args) else indent + capture_block { block.call(data) } end end end "<tbody>\n#{html.join("\n")}\n</tbody>\n".html_safe end |