I have something like:
<%= @votes %>
With just outputs a string like:
123
Is there a simple way to wrap each character with some html with a helper?
<span class="outerclass">
<span class="innerclass">
1
</span>
</span>
<span class="outerclass">
<span class="innerclass">
2
</span>
</span>
<span class="outerclass">
<span class="innerclass">
3
</span>
</span>
You could create a helper similar to this:
Then use it like this (erb):
Update: The above example represents one way to pass block level content to a helper, but it’s worth noting that this particular example can be simplified by just using the
each_charmethod on the string and avoiding the helper altogether: