Module: RKit::Grid::ActionViewExtension
- Defined in:
- lib/r_kit/grid/action_view_extension.rb
Instance Method Summary collapse
- #col__tag(col_size, options = {}, &block) ⇒ Object
- #col_tag(options = {}, &block) ⇒ Object
- #container__tag(col_size, collection, options = {}, &block) ⇒ Object
- #container_tag(options = {}, &block) ⇒ Object
- #html_options(options = {}, defaults = {}) ⇒ Object
- #proc_options(instance, options = {}) ⇒ Object
- #row__tag(col_size, collection, options = {}, &block) ⇒ Object
- #row_tag(options = {}, &block) ⇒ Object
- #rows__tag(col_size, collection, options = {}, &block) ⇒ Object
Instance Method Details
#col__tag(col_size, options = {}, &block) ⇒ Object
38 39 40 |
# File 'lib/r_kit/grid/action_view_extension.rb', line 38 def col__tag col_size, = {}, &block col_tag .merge(col_size: col_size), &block end |
#col_tag(options = {}, &block) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/r_kit/grid/action_view_extension.rb', line 30 def col_tag = {}, &block [:instance], = (, {class: "col-#{ [:col_size] }"}) content_tag([:tag] || :div, ){ block.call([:instance]) } end |
#container__tag(col_size, collection, options = {}, &block) ⇒ Object
60 61 62 63 |
# File 'lib/r_kit/grid/action_view_extension.rb', line 60 def container__tag col_size, collection, = {}, &block = .delete(:rows) || {} container_tag(){ send("rows_#{ col_size}_tag", collection, , &block) } end |
#container_tag(options = {}, &block) ⇒ Object
20 21 22 23 |
# File 'lib/r_kit/grid/action_view_extension.rb', line 20 def container_tag = {}, &block = (, {class: :container}) content_tag [:tag] || :div, , &block end |
#html_options(options = {}, defaults = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/r_kit/grid/action_view_extension.rb', line 8 def = {}, defaults = {} id = [:id] classes = "#{ defaults[:class] } #{ [:class] }" classes += " off-#{ [:offset] }" if [:offset] { :id => id, :class => classes } end |
#proc_options(instance, options = {}) ⇒ Object
2 3 4 5 6 |
# File 'lib/r_kit/grid/action_view_extension.rb', line 2 def instance, = {} ([:proc_options] || []).each do |key, proc| [key] = proc.call(instance) end end |
#row__tag(col_size, collection, options = {}, &block) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/r_kit/grid/action_view_extension.rb', line 42 def row__tag col_size, collection, = {}, &block = [:cols] || {} cols_buffer = collection.inject ActiveSupport::SafeBuffer.new do |safe_buffer, instance| safe_buffer.safe_concat send("col_#{ col_size }_tag", .merge(instance: instance), &block) end row_tag(){ cols_buffer } end |
#row_tag(options = {}, &block) ⇒ Object
25 26 27 28 |
# File 'lib/r_kit/grid/action_view_extension.rb', line 25 def row_tag = {}, &block = (, {class: :row}) content_tag [:tag] || :div, , &block end |
#rows__tag(col_size, collection, options = {}, &block) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/r_kit/grid/action_view_extension.rb', line 52 def rows__tag col_size, collection, = {}, &block rows_buffer = collection .in_groups_of(12 / col_size, false) .inject ActiveSupport::SafeBuffer.new do |safe_buffer, collection| safe_buffer.safe_concat send("row_#{ col_size }_tag", collection, , &block) end end |