Module: MinimumViableProduct::BootstrapHelper
- Defined in:
- app/helpers/minimum_viable_product/bootstrap_helper.rb
Instance Method Summary collapse
- #col_groups_of(count, collection, opts = {}) ⇒ Object
- #row_groups_of(count, collection, opts = {}, &block) ⇒ Object
Instance Method Details
#col_groups_of(count, collection, opts = {}) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/helpers/minimum_viable_product/bootstrap_helper.rb', line 3 def col_groups_of(count, collection, opts={}) return if collection.blank? html = [] collection.in_groups_of(count).each do |groups| groups.compact.each do |obj| html << capture do content_tag :div, class: ["col-md-#{12/count.to_f.floor}", opts[:col_class]].compact.join(' ') do yield obj end end.html_safe end end concat html.join.html_safe end |
#row_groups_of(count, collection, opts = {}, &block) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/helpers/minimum_viable_product/bootstrap_helper.rb', line 19 def row_groups_of(count, collection, opts={}, &block) return if collection.blank? html = [] subsetsize = (collection.count/count.to_f) subsetsize.ceil.times do |i| subset = collection[count*i...((count*i)+count)] html << capture do content_tag :div, class: ["row",opts[:row_class]].compact.join(' ') do capture do col_groups_of(count, subset, opts, &block) end end end.html_safe end concat html.join.html_safe end |