Module: Maglove::Widgets::Columns::Helpers
- Defined in:
- lib/maglove/widgets/columns.rb
Instance Method Summary collapse
- #column(row, &block) ⇒ Object
- #columns_widget(options = {}, &block) ⇒ Object
- #columns_widget_compose(key, options = {}, &block) ⇒ Object
Instance Method Details
#column(row, &block) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/maglove/widgets/columns.rb', line 48 def column(row, &block) # get and increase span next_span = row.next_span if next_span phone_cols = row.[:collapse_options] == "xs" ? next_span : "12" haml_tag :div, class: "column col-#{phone_cols} col-tablet-#{next_span} col-#{row.options[:collapse_options]}-#{next_span}" do yield if block drop_container end else haml_tag :pre do haml_concat "ERROR: Row does not allow column at position #{row.column_count}" end end end |
#columns_widget(options = {}, &block) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/maglove/widgets/columns.rb', line 64 def ( = {}, &block) (Widgets::Columns.new()) do || haml_tag :div, . do yield() if block end end end |
#columns_widget_compose(key, options = {}, &block) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/maglove/widgets/columns.rb', line 72 def (key, = {}, &block) = Widgets::Columns.new() items = variable(key, []) # calculate row and column count row_count = (items.length.to_f / .total_columns).ceil col_count = .total_columns (0...row_count).each do |row_index| () do |row| (0...col_count).each do |col_index| index = (row_index * col_count) + col_index yield(row, items[index]) unless items[index].nil? end end end end |