HAML Cheat Sheet: by Via

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

HAML Cheat Sheet

by J Lee (specialbrand) via cheatography.com/395/cs/188/

Doctype Elements Implicit Div Elements

!!! <!DOCTYPE html PUBLIC "- %p #collection


//W3C//DTD XHTML 1.0 A paragraph .item
Transitional//EN" %strong bold .description What a cool item!
"http://www.w3.org/TR/xhtml1/DTD/ is compiled to: is compiled to:
xhtml1-transitional.dtd"> <p>A paragraph <strong>bold</strong></p> <div id='collection'>
!!! 5 <!DOCTYPE html> <div class='item'>
Attributes <div class='description'>What a cool item!
!!! Strict <!DOCTYPE html PUBLIC "-
</div>
//W3C//DTD XHTML 1.0 %html{:xmlns =>
</div>
Strict//EN" "http://www.w3.org/1999/xhtml", "xml:lang" =>
</div>
"http://www.w3.org/TR/xhtml1/DTD/ "en", :lang => "en"}
xhtml1-strict.dtd"> is compiled to:
Comments
!!! <!DOCTYPE html PUBLIC "- <html xmlns='http://www.w3.org/1999/xhtml'
Frameset //W3C//DTD XHTML 1.0 xml:lang='en' lang='en'></html> HTML Comments: /
Frameset//EN" %peanutbutterjelly
"http://www.w3.org/TR/xhtml1/DTD/ Self-Closing Tags / This is the peanutbutterjelly element
xhtml1-frameset.dtd"> I like sandwiches!
%br
is compiled to:
%meta{'http-equiv' => 'Content-Type', :content
Filters <peanutbutterjelly>
=> 'text/html'}
<!-- This is the peanutbutterjelly ellement -->
%p is compiled to:
I like sandwiches!
:markdown <br /> </peanutbutterjelly>
# Heading <meta http-equiv='Content-Type'
Haml Comments: -#
Hello, *World* content='text/html' />
%p foo
is compiled to:
-# This is a comment
<p> Escaping HTML %p bar
<h1>Heading</h1>
&= "I like cheese and crackers" is compiled to:
<p>Hello, <em>World</em></p>
compiles to: <p>foo</p>
</p>
I like cheese &ampamp; crackers <p>bar</p>

Some Filters Available To Use


Class and ID
:plain Does not parse the filtered text. This
%div#things
is useful for large blocks of text
%span#rice Chicken Fried
without HTML tags, when you dont
%p.beans{ :food => 'true' } The magical fruit
want lines starting with . or - to be
%h1.class.otherclass#id La La La
parsed.
is compiled to:
:javascri Surrounds the filtered text with
<div id='things'>
pt <script> and CDATA tags. Useful for
<span id='rice'>Chicken Fried</span>
including inline Javascript.
<p class='beans' food='true'>The magical
:css Surrounds the filtered text with fruit</p>
<style> and CDATA tags. Useful for <h1 class='class otherclass' id='id'>La La
including inline CSS. La</h1>
:sass Parses the filtered text with Sass to </div>
produce CSS output.

:textile Parses the filtered text with Textile.

:makuru Parses the filtered text with Maruku,


which has some non-standard
extensions to Markdown.

By J Lee (specialbrand) Published 5th January, 2012. Sponsored by CrosswordCheats.com


cheatography.com/specialbrand/ Last updated 5th June, 2014. Learn to solve cryptic crosswords!
www.specialbrand.net Page 1 of 1. http://crosswordcheats.com

You might also like