Showing posts with label dynamic html tag loopc reation. Show all posts
Showing posts with label dynamic html tag loopc reation. Show all posts

Saturday, July 31, 2010

Dynamic html tag loop creation

arr = [1,2,3,4]
str = ''
i = 0
arr.each do |a|
        if i % 3 == 0
                str<<"#{a}"
        else
                str<<"#{a}"
        end
        i = i+1
        if i % 3 == 0 || arr.length == i
             str <<"
"
        end
end

puts str.inspect

output is like :

  • 1

    2

    3

  • 4