Quick Tip: Hidden divs in HAML
Posted by Vince Wadhwani on Apr 21, 2008
I had the chance to play around with haml the other day. Those of you who don't know haml might want to check the above link and come back. For the lazy people, it's basically an alternative markup aiming to make the views more readable or "beautiful". Whether it succeeds or not is not the point of this tip. Rather, if you're using haml, and want to create a hidden div, I'm here to show you how to do it.
A hidden div using standard markup might look like this:
<div id ="foo" style="display:none"> My code goes here! </div>
Taking that and convert it to haml and you get:
%div{:id => "foo", :style => 'display:none'}
My code goes here!
Of course with haml you have to be extra careful that you nest things properly with two spaces (reminds anyone else of fortran 77?) so if the above code doesn't work for you, be sure you've got your spaces (not tabs) in order.