Skip to content

Aug 11 / Rupak Ganguly

How to manage whitespace around text in Haml?

While creating some html content using Haml, I ran into the problem of removing the extra space that Haml puts in after a link text. Here is what I wanted the link text to look like:

Check out my website.

But, what I got was: (note the extra space before the period)

Check out my website .

It drove me nuts trying to fix it before I discovered the cool new Haml helpers. The particular helper in question that fixed the above issue is the succeed helper method as shown below:

   Check out my
   = succeed '.' do
       %a{href: ''} website

Hope that helps you to write good html using Haml.

If you have other Haml tricks you know of, let me know in the comments section.

Leave a Comment