Vidar
03 February 2009
Haml and pre tag indention
I use Haml in most of my applications. It’s a great tool since it makes it so easy to read and develop your view code. Haml uses indentation similar to Python. However, today, I ran into problems. In this blog, if I write some example code, I use <pre> tags to preserve white space. Using Haml, the <pre> code will automatically be indented in addition to white space inside the tag. I used to have this code in my view:
.post_content
= @post.body_html
This code will give unwanted indentation. I changed it to this, using the :preserve filter in Haml (read about the Haml Filters ) and it behaves as expected.
.post_content
:preserve
#{@post.body_html}
Back to what I was supposed to do today…
« Back to posts Write a new comment