class Grapple::Components::HtmlBody

Public Instance Methods

render(*options, &block) click to toggle source
# File lib/grapple/components/html_body.rb, line 15
def render(*options, &block)
        options = options[0] || {}
        
        wrap_row = if options[:tr].nil?
                self.tr
        elsif options[:tr] === false
                false
        else
                options[:tr]
        end
        
        args = {}
        if records.empty? && !options[:no_rows_html].nil?
                html = ["<tr><td colspan=\"#{columns.length}\">#{options[: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