Skip to content

Instantly share code, notes, and snippets.

@samueljseay
Forked from them0nk/haml_cheatsheet.haml
Last active December 29, 2015 01:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samueljseay/7592390 to your computer and use it in GitHub Desktop.
Save samueljseay/7592390 to your computer and use it in GitHub Desktop.
-# HTML5 doctype
!!! 5
!!! strict
!!! XML
%html
-#ie conditionals
/[if IE]
%a{ href: "http://www.mozilla.com/en-US/firefox/" }
%h1 Get Firefox
%div.myclass1
-# is equivalent to
.myclass1
%div#myid.myclass
.myclass#myid
#myid.myclass
%table.aclass#mytableid
%table#mytableid{class: "aclass"}
%table.aclass{id: "mytableid"}
%table{id: "mytableid", class: "aclass"}
.myclass1.myclass2
.myclass2.myclass1
-# This line is a ruby comment
-# The Next line is a ruby statement which will not get printed
- @array = [1,2,3]
- @myclass = "highlight"
-# data attributes
.myclass{ data: { attribute: "foo" }}
-# or
.myclass{ :"data-attribute" => "foo" }
-#filters
%p
-#Simply passes the filtered text through to the generated HTML.
:plain
Lorem ipsum...
-#Surrounds the filtered text with a CDATA escape.
:cdata
Lorem ipsum...
-#Works the same as :plain, but HTML-escapes the text before placing it in the document.
:escaped
Lorem ipsum...
-#Parses the filtered text with ERB – the Rails default template engine.
:erb
Lorem ipsum...
-#Parses the filtered text with Textile. Only works if RedCloth is installed.
:textile
Lorem ipsum...
-#Parses the filtered text with Markdown. Only works if RDiscount, RPeg-Markdown, Maruku, or BlueCloth are installed
:markdown
Lorem ipsum...
-#Parses the filtered text with Maruku, which has some non-standard extensions to Markdown.
:maruku
Lorem ipsum...
%ul
- @array.each do |e|
-# Below all syntax are equivalent
%li{:class => @myclass, :id => e }
= e
%li {:class => @myclass, :id => e} #{e}
%li= e
-#inline scripts
:javascript
var number = 42;
-#inline coffeescripts
:coffee
number = 42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment