Flow grid is a simple Rails plugin for creating grid-like views of collections. The data can flow from left-to-right (row) or top-to-bottom (column). The column orientation often has better usability than row orientation.
script/plugin install git://github.com/bsiggelkow/flow_grid.git
script/plugin install git://github.com/bsiggelkow/flow_grid.git -r rails-2.3
rails plugin install git://github.com/bsiggelkow/flow_grid.git -r rails-3.0
Basic usage:
<%= flow_grid collection, # collection (must respond to [])
:partial => 'my_partial', # partial that renders the collection item
:columns => 3, # number of columns
:flow => :vertial, # orientation (horizontal | vertical)
:fill => ' ', # fill empty cells with this value
:class => 'flow_grid' # this and all succeeding options passed as html attributes to table tag
%>
Without a partial:
<%= flow_grid collection, :columns => 3 %>
With a block (with each result of the block passed to the partial):
<%= flow_grid( collection, :partial => '_some_partial', :columns => 4 ) { |obj| obj.to_s.capitalize } %>
FlowGrid works its magic the good old-fashioned way – TABLES! Seriously, some HTML is just a bit easier to render tables and this is one of them. I have considered creating a “table-less” option (using a combination styled divs and unordered lists); but generally I find the solution more cumbersome than the table-based alternative.
github.com/bsiggelkow/flow_grid
Copyright © 2010 Bill Siggelkow, released under the MIT license