Sha256: 1059568c17b40c1a0c1390934bc09200e7686f9c683b911109dffe456cbad4d4
Contents?: true
Size: 1.71 KB
Versions: 2
Compression:
Stored size: 1.71 KB
Contents
module EaselHelpers module Helpers module TableHelper def zebra_row(options = {}, &block) cycle_list = options.delete(:cycle_list) || [nil, "alt"] css_classes = [cycle(*cycle_list)] << options.delete(:class) html = content_tag(:tr, capture(&block), options.merge(:class => clean_css_classes(css_classes))) concat(html) end def recordset(*args, &block) options = args.extract_options! options[:table] ||= {} headers = [] (options[:headers] || []).each_with_index do |header, index| head = [header].flatten opts = head.extract_options! css_classes = [] << case index when 0 then "first" when (options[:headers].size - 1) then "last" end css_classes << opts.delete(:class) headers << if head.first =~ /^\<th/ th = Hpricot(head.first) th.at("th")["class"] = clean_css_classes([th.at("th")['class'].to_s, css_classes]) th.to_html else content_tag(:th, head.first, opts.merge(:class => clean_css_classes(css_classes))) end end table_css_classes = ["recordset"] << options[:table].delete(:class) << args css_classes = clean_css_classes(table_css_classes, {"last" => last_column}) html = clean_column css_classes do content_tag(:table, content_tag(:thead, content_tag(:tr, headers.to_s)) + capture(&block), options[:table].merge(:class => css_classes, :cellspacing => 0)) end reset_cycle concat(html) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fusionary-easel_helpers-0.2.1 | lib/easel_helpers/helpers/table_helper.rb |
fusionary-easel_helpers-0.2.2 | lib/easel_helpers/helpers/table_helper.rb |