Sha256: 2e1ff5aeae5b2b13368d7c811ccd5f81d3ddab7e636027cb36146c4bd0a6b45d
Contents?: true
Size: 1016 Bytes
Versions: 2
Compression:
Stored size: 1016 Bytes
Contents
module SimpleTableFor def field(content, options = {}) <<-TD.html_safe <td id='#{options[:id]}' class='#{options[:class]}'> #{content} </td> TD end # Usage: # <%= table_for @posts, %w[Title Text Date Comments\ count -] do |post| %> # <%= field post.title %> # <%= field post.text %> # <%= field post.date %> # <%= field post.comments.count %> # <%= field link_to('View', post) %> # <% end %> def table_for(collection, heads, options = {}) heads = heads.map{|h| "<th>#{h}</th>".html_safe }.join('') rows = collection.map do |obj| "<tr>#{capture{ yield obj }}</tr>".html_safe end.join('') <<-TABLE.html_safe <table id='#{options[:id]}' class='#{options[:class]}'> <thead> <tr> #{heads} </tr> </thead> <tbody> #{rows} </tbody> </table> TABLE end end ActionView::Base.send :include, SimpleTableFor if defined? ActionView::Base
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
simple_table_for-0.0.2 | lib/simple_table_for.rb |
simple_table_for-0.0.1 | lib/simple_table_for.rb |