Sha256: 84c79190ed6a55c5b21cf87c577419d9832aae501869a444c736146b0acfd555
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
module TableCloth module Presenters class Default < ::TableCloth::Presenter def render_table wrapper_tag :table do render_header + render_rows end end def render_rows wrapper_tag :tbody do v.raw objects.inject('') {|r, object| r + render_row(object) } end end def render_row(object) wrapper_tag :tr do v.raw table.columns.inject('') {|tds, (key, column)| tds + render_td(column, object) } end end def render_td(column, object) td_options = column.options[:td_options] || {} value = column.value(object, view_context, table) if value.is_a?(Array) options = value.pop value = value.shift td_options.update(options) end wrapper_tag(:td, value, td_options) end def render_header wrapper_tag :thead do wrapper_tag :tr do v.raw column_names.inject('') {|tags, name| tags + wrapper_tag(:th, name) } end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
table_cloth-0.2.3 | lib/table_cloth/presenters/default.rb |
table_cloth-0.2.2 | lib/table_cloth/presenters/default.rb |