Sha256: 85e7b7d34eac416d1786250bb1ec5ddb733b46d6814d52747f8b8c67b53cce89
Contents?: true
Size: 1.5 KB
Versions: 2
Compression:
Stored size: 1.5 KB
Contents
require 'table_helper/html_element' require 'table_helper/header' require 'table_helper/body' require 'table_helper/footer' module PluginAWeek #:nodoc: module TableHelper # Represents a table that is displaying data for multiple objects within # a collection. class CollectionTable < HtmlElement def initialize(collection, options = {}, html_options = {}) #:nodoc: super(html_options) options.assert_valid_keys( :class, :footer, :header ) @options = options.reverse_merge( :header => true, :footer => false ) @html_options.reverse_merge!( :cellspacing => '0', :cellpadding => '0' ) @header = Header.new(collection, options[:class]) @body = Body.new(collection, @header) @footer = Footer.new(collection) end # Builds the table by rendering a header, body, and footer. def build(&block) @body.build # Build with the defaults elements = [] elements << @header.builder if @options[:header] elements << @body elements << @footer if @options[:footer] yield *elements if block_given? @content = '' elements.each {|element| @content << element.html} @content end private def tag_name 'table' end def content @content end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
table_helper-0.0.5 | lib/table_helper/collection_table.rb |
table_helper-0.0.4 | lib/table_helper/collection_table.rb |