Tag Archives: erb

Trivial Rails tip: easy html spaces

For when you don’t want to type   a dozen times, add this to application_helper.rb:
def nbsp(n=1)
    n.times.map {” ”}
end
In a view:
<%= nbsp 5 %>
replaces
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

addthis_url = ‘http%3A%2F%2Fwww.alandelevie.com%2F2010%2F07%2F16%2Ftrivial-rails-tip-easy-html-spaces%2F’;
addthis_title = ‘Trivial+Rails+tip%3A+easy+html+spaces’;
addthis_pub = ”;