Sha256: b383d835d39fffcffbaee0e8205f96884dda895824712722f653a8938c300965
Contents?: true
Size: 887 Bytes
Versions: 1
Compression:
Stored size: 887 Bytes
Contents
module Represent module GridHelper def grid_for(array, options = {}, &block) return "" if array.empty? columns = options[:columns] || 3 (array / columns).each do |row| yield row end end def row_for(array, options = {}, &block) return "" if array.empty? array.each_with_index do |node, i| attributes = options.has_key?(:li_attributes) ? options[:li_attributes] : {} attributes[:class] ||= "" if i == 0 and options.has_key?(:first) attributes[:class] << "#{options[:first]}" elsif i == array.length - 1 and options.has_key?(:last) attributes[:class] << "#{options[:last]}" end haml_tag :li, attributes do if block_given? yield node, i else haml_concat node.title end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
represent-0.0.1.5 | lib/represent/grid_helper.rb |