To create n spans next to each other I do:
<% n.times do |i| %>
<%= content_tag(:span, i + 1) %>
<% end %>
The problem is that there is a space between the created spans.
So, I tried to create them in one line:
<% spans = "".html_safe %>
<% n.times do |i| %>
<% spans += content_tag(:span, i + 1) %>
<% end %>
<%= spans %>
Indeed, now the spans are close to each other (no space in between).
However, I feel that this workaround is dirty.
How could achieve the same with a cleaner code ?
If you check the HTML source you can see it’s not a space, but a line-break (which in HTML is displayed as a space). If you put everything in one line the spaces are gone:
This gives me the following output: