Professional Documents
Culture Documents
• Well-formatted markup
• DRY
<one>
<two>
<three>Hello, World</three>
</two>
</one>
Using Haml
• Brackets {} represent a Ruby hash that is used for
specifying the attributes of an element.
<head name='document_head'>
<script src='javascripts/script_9.js' type='text/javascript'></script>
</head>
Using Haml
• Square brackets [] use the dom_id and
dom_class methods to tag the element.
%div[@user]
%div[290] Hello!
%div#things
%span#rice Chicken Fried
%p.beans{ :food => 'true' } The magical fruit
%h1.class.otherclass#id La La La
<div id='things'>
<span id='rice'>Chicken Fried</span>
<p class='beans' food='true'>The magical fruit</p>
<h1 class='class otherclass' id='id'>La La La</h1>
</div>
Using Haml
• = is a shortcut for inserting Ruby code into an
element.
#hello_1= "<span>Hello</span>"
#hello_2=h "<span>Hello</span>"
<div id='hello_1'><span>Hello</span></div>
<div id='hello_2'><span>Hello</span></div>
Using Haml
• - designates a Ruby block that should not be outputted.
(notice no need for end)
- (12...14).each do |i|
%p= i
%p See, I can count!
%p.array
- if [].blank?
%span.blank The array was blank.
- else
%span.notblank The array was not blank.
<p>12</p>
<p>13</p>
<p>See, I can count!</p>
<p class='array'>
<span class='blank'>The array was blank.</span>
</p>
Sass
Syntactically Awesome StyleSheets
Haml 1.7.2
ERB
Performance
Haml
ERB
Erubis
Markaby
Performance
Haml
ERB
Erubis
Haml in the Wild
• MyStock mystock.com
• Rails 2 with Haml trunk