Question

i'm using rails4/ruby2 and haml, trying to build a grid layout using helper So i have this grid structure in haml:

#container
  .column
    #title
    .thumb
      = link_to '', title: '' do
        = image_tag '', alt: '', size: '196x196'
        %span.caption
          %p.title

    .thumb
      = link_to '', title: '' do
        = image_tag '', alt: '', size: '196x196'
        %span.caption
          %p.title

  .column
    #title
    .thumb
      = link_to '', title: '' do
        = image_tag '', alt: '', size: '196x196'
        %span.caption
          %p.title

    .thumb
      = link_to '', title: '' do
        = image_tag '', alt: '', size: '196x196'
        %span.caption
          %p.title

Someone can help me to make a helper for build this grid structure? i want to do this for don't be so DRY repeating many times the elements

No correct solution

OTHER TIPS

Use each_slice! Assuming you have an array of images:

- images.each_slice(2) do |image_column|
  .column
    #title
    - image_column.each do |image|
      .thumb
        = link_to '', title: '' do
          = image_tag image.path, alt: '', size: '196x196'
          %span.caption
            %p.title
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top