Today I Learned

hashrocket A Hashrocket project

How to avoid additional spaces when rendering HTML

Many, many moons ago 🌕🌗🌑🌓🌕 before Rails 3, ERB would add additional spaces before and after rendering HTML content, using <% %>.

To avoid those additional spaces you can use <%- %> or <% -%>

I share this in case you were like me, checking out some older code and didn't know what was going on here.

See More #rails TILs
Looking for help? Hashrocket has been an industry leader in Ruby on Rails since 2008. Rails is a core skill for each developer at Hashrocket, and we'd love to take a look at your project. Contact us and find out how we can help you.