Reputation: 8487
I have the following html, for example, and I need to make it repeat several times. Without using parcials and other stuff, how can I easily repeat it?
<div>This is a div</div>
I am looking for something like this:
<%= repeat 4 times %>
<div>This is a div</div>
<% end %>
Upvotes: 0
Views: 223
Reputation:
#!/usr/bin/env ruby
3.times do
puts "This will be printed 3 times"
end
print "Enter a number: "
num = gets.chomp.to_i
num.times do
puts "Ruby is great!"
end
This is an example of times loop in ruby. Hope it helped
Upvotes: 0
Reputation: 3243
Using Ruby times
method:
<% 4.times do %>
<div>This is a div</div>
<% end %>
Upvotes: 3