This question is similar to this one, but with an extra wrinkle:
Auto-removing all newlines from Haml output
Suppose you’re constructing a comma-separated list of links with code like this:
- foos.each_with_index do |foo, i|
= ', ' if i > 0
= link_to foo.name, foo
How do you do that without getting whitespace in front of the comma? I don’t see any way to do this with the existing alligator operators or surround/precede/succeed.
Is there some way to rewrite the loop so you can use these operators?
Since link_to is just a helper that returns a string, you can do it in a single statement:
However, you probably want to extract this code into a helper and write tests.