how do I create a table using loops and haml with ruby?

后端 未结 3 1188
旧时难觅i
旧时难觅i 2021-02-02 10:53

I\'m trying to make an html table that looks like this:

1 2 3 4 5
1 2 3 4 5
1 2 3 4 5

My data structure is like this: @f_ary = [ 1..250]

<
3条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-02 11:26

    update

    This could be the most un-ruby way of doing it, (I did this around 3 years back). So

    check out above answers & they are much more better

    I will just keep this answer without deletion, just as a reference on, how NOT to do it... ;)


    Have an internal counter in the view, when it comes to 5, add a . psudo will look some thing like this

    couneter = 0 
    
    @items.each |item|
       if counter == 0
        
       end
       if counter != 5
         item
         counter ++
       end
       if counetr == 5
         
         counetr = 0
       end 
      
    end
       
    
    end
    

    I hope u get the idea

    cheers

    sameera

提交回复
热议问题