Reputation: 5810
How do I achieve this?
In a controller
@arr = ["<one>", "<two>"]
In a view (haml)
= @arr.join("<br>")
As you guess, "<br>"
shouldn't be escaped. So the result would be like the following.
<one%gt;<br><two%gt;
How do I do that?
Thanks.
Sam
Upvotes: 0
Views: 1942
Reputation: 65467
You could roll your own:
arr = ["<one>", "<two>"]
''.html_safe.tap {|x|
arr.each_with_index { |el, ix|
x << el
x << raw("<br/>") if ix < arr.size-1
}
}
Also look at the Array.join code in Rails
Upvotes: 1