CONTENTS OF THIS SITE

OUR OTHER CONTENTS

RECENT BLOG ENTRIES

HAML Tip

January 28th, 2008 by comment desi

So we were having an issue with haml and using a text-area output. It had indentation when it should not have and double indented after doing a save. A quick google search brought me to Ray Morgan’s Blog for the answer. Basically instead of using the = sign use a ~ and it will preserve whitespace. Thanks Ray. I am posting it here so I will remember where to find it if/when I forget what the answer was in the future.

Comments

3 Responses to “HAML Tip”

  1. gregf says:


    Just got bit by the same thing a couple days ago. I found someone on the haml mailing list with the same issue. They no longer mention ~ in the manual either,from what the dev said who respond. They are recommending people use the find_and_preserve helper method. It excepts a block. Good tip to spread around though. I think it’s something that bites most people getting used to haml.

  2. Bob Aman says:


    I had a similar problem because I wanted to output this with Haml:

    <pre><code>some multiline code</code></pre>

    To avoid indentation problems, all the newlines need to be replaced with character entities, and the code element has to be on the same line as the pre element.

    Fiddled around with writing a filter that would accomplish this, but eventually opted for a helper method instead since I realized that I probably would also want to do syntax highlighting.

  3. desi says:


    Thanks Greg and Bob for the info. I’ll check out the helpers.

Got something to say?