SlideShare a Scribd company logo
Haml and Sass
   An Introduction
What?
• Templating languages
• Haml generates html
• Sass generates css
• Can be used independently
• They help front-end
  development suck less
Why?

• Markup should be beautiful
• Markup should be DRY
• Markup should be well indented
Basics

• White space defined structure
• Self closing tags
Example
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "http://www.w3.org/TR/xhtml1/
DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>
       Ethan’s Awesome Webpage
    </title>
  </head>
</html


     !!!
     %html
       %head
         %title Ethan’s Awesome Webpage
Example
<div class=”latin” id=”content”>
  lorem ipsum
</div>


 %div.latin#content lorem ipsum

  .latin#content lorem ipsum
Example
.posts                           <div class=”posts”>
  -@posts.count.each do |post|     <% @posts.count.each do |post|%>
    %span.title= post.name           <span class=”title”>
    %p= post.text                       <%= post.name %>
                                     </span>
                                     <p>
                                        <%= post.text %>
                                     </p>
                                   <% end %>
                                 </div>
Sass
Basics
.content
  padding: 5px
  margin-right: auto
  margin-left: auto
  img
    border: 1px solid black
Nesting
.h1                .h1 {
  font:              font-weight: bold;
    weight: bold     font-size: 1.2em; }
    size: 1.2em    .h1 img {
  img                margin: 5px; }
    margin: 5px
Variables
!margin = 10px        h1 {
!padding = 5px          padding: 5px;
!green = DarkGreen      margin: 10px;
!blue = DarkBlue        color: DarkGreen; }

h1                    h2 {
 padding = !padding     padding: 5px;
 margin = !margin       margin: 10px;
 color = !green         color: DarkBlue; }
h2
 padding = !padding
 margin = !margin
 color = !blue
Mixins
                              #data th {
=table-scaffolding(!margin)     text-align: center;
  th                            font-weight: bold;
     text-align: center       }
     font-weight: bold        #data td, #data th {
  td, th                        padding: 2px;
     padding: 2px               margin: 10px;
      margin = !margin        }
#data
  +table-scaffolding(10px)
Cool projects using
       Haml/Sass

•   StaticMatic - Adds the joy of dynamic websites to
    static ones

•   DynamicMatic - Adds a Sinatra back-end to
    StaticMatic
Resources

• haml-lang.com
• sass-lang.com
• html2haml / css2sass
• Live rendering http://rendera.heroku.com/
Questions?
Thanks

More Related Content

PDF
Css introduction
PDF
CSS and Layout
ODP
The ABCs of HTML
PDF
HTML & CSS Basics
PPTX
Code For Every Librarian
PDF
PDF
Implementing Awesome: An HTML5/CSS3 Workshop
PDF
The Future Of CSS
Css introduction
CSS and Layout
The ABCs of HTML
HTML & CSS Basics
Code For Every Librarian
Implementing Awesome: An HTML5/CSS3 Workshop
The Future Of CSS

What's hot (20)

PDF
PDF
CSS Box Model and Dimensions
PDF
Haml And Sass In 15 Minutes
PDF
Basic HTML & CSS
PDF
Haml And Sass: Put your markup on a diet
PDF
Pemrograman Web 4 - Bootstrap 3
PPTX
From PSD to WordPress Theme: Bringing designs to life
PDF
Php workshop L01 CSS
PPTX
Managing responsive websites with css preprocessors.
PPTX
CSS Basics - Stylesheets and Color
PPTX
Less css
PPTX
Css frameworks
PPT
Web Design 101
PPTX
Cascading style sheet part 2
KEY
Intro to SASS CSS
ODP
Sass presentation
PDF
01 Introduction To CSS
KEY
Artdm171 Week5 Css
PDF
CSS Reset
PDF
Drupal front-end performance
CSS Box Model and Dimensions
Haml And Sass In 15 Minutes
Basic HTML & CSS
Haml And Sass: Put your markup on a diet
Pemrograman Web 4 - Bootstrap 3
From PSD to WordPress Theme: Bringing designs to life
Php workshop L01 CSS
Managing responsive websites with css preprocessors.
CSS Basics - Stylesheets and Color
Less css
Css frameworks
Web Design 101
Cascading style sheet part 2
Intro to SASS CSS
Sass presentation
01 Introduction To CSS
Artdm171 Week5 Css
CSS Reset
Drupal front-end performance
Ad

Viewers also liked (6)

PDF
Our Adventure with MongoDB
PDF
Mongo chicago
KEY
ActiveRecord is Rotting Your Brian
KEY
The ABCs of Scaling MongoDB
PPTX
#IAEM November 2010
PDF
On the Papers of Giants
Our Adventure with MongoDB
Mongo chicago
ActiveRecord is Rotting Your Brian
The ABCs of Scaling MongoDB
#IAEM November 2010
On the Papers of Giants
Ad

Similar to Haml and Sass Introduction (20)

PDF
DRY cross-browser CSS with SASS
PDF
Compass And Sass(Tim Riley)
PDF
Sassive Aggressive: Using Sass to Make Your Life Easier (NSWG Version)
KEY
Sass Essentials at Mobile Camp LA
PDF
CSS3 Talk (PDF version)
PDF
CSS3 Talk at SF HTML5 Meetup
KEY
Using Sass - Building on CSS
KEY
Stylesheets of the future with Sass and Compass
KEY
Simplifying CSS With Sass
PDF
Class 4 handout two column layout w mobile web design
PDF
CSS Quick Reference / Cheat Sheet - Scott DeLoach, ClickStart
PDF
Introdução a CSS
PDF
KEY
Demystifying CSS & WordPress
KEY
Organizing & Simplifying CSS [with Sass]
PDF
CSS Extenders
PDF
Intro to HTML & CSS
PPTX
[SUTD GDSC] Intro to HTML and CSS
PDF
Think Vitamin CSS
PDF
Accelerated Stylesheets
DRY cross-browser CSS with SASS
Compass And Sass(Tim Riley)
Sassive Aggressive: Using Sass to Make Your Life Easier (NSWG Version)
Sass Essentials at Mobile Camp LA
CSS3 Talk (PDF version)
CSS3 Talk at SF HTML5 Meetup
Using Sass - Building on CSS
Stylesheets of the future with Sass and Compass
Simplifying CSS With Sass
Class 4 handout two column layout w mobile web design
CSS Quick Reference / Cheat Sheet - Scott DeLoach, ClickStart
Introdução a CSS
Demystifying CSS & WordPress
Organizing & Simplifying CSS [with Sass]
CSS Extenders
Intro to HTML & CSS
[SUTD GDSC] Intro to HTML and CSS
Think Vitamin CSS
Accelerated Stylesheets

Recently uploaded (20)

PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Approach and Philosophy of On baking technology
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
sap open course for s4hana steps from ECC to s4
PDF
NewMind AI Weekly Chronicles - August'25-Week II
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Spectroscopy.pptx food analysis technology
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Programs and apps: productivity, graphics, security and other tools
The Rise and Fall of 3GPP – Time for a Sabbatical?
Encapsulation_ Review paper, used for researhc scholars
Unlocking AI with Model Context Protocol (MCP)
Review of recent advances in non-invasive hemoglobin estimation
Approach and Philosophy of On baking technology
Advanced methodologies resolving dimensionality complications for autism neur...
Network Security Unit 5.pdf for BCA BBA.
sap open course for s4hana steps from ECC to s4
NewMind AI Weekly Chronicles - August'25-Week II
The AUB Centre for AI in Media Proposal.docx
Per capita expenditure prediction using model stacking based on satellite ima...
Reach Out and Touch Someone: Haptics and Empathic Computing
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Chapter 3 Spatial Domain Image Processing.pdf
MYSQL Presentation for SQL database connectivity
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Spectroscopy.pptx food analysis technology

Haml and Sass Introduction

  • 1. Haml and Sass An Introduction
  • 2. What? • Templating languages • Haml generates html • Sass generates css • Can be used independently • They help front-end development suck less
  • 3. Why? • Markup should be beautiful • Markup should be DRY • Markup should be well indented
  • 4. Basics • White space defined structure • Self closing tags
  • 5. Example <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/ DTD/xhtml1-transitional.dtd"> <html> <head> <title> Ethan’s Awesome Webpage </title> </head> </html !!! %html %head %title Ethan’s Awesome Webpage
  • 6. Example <div class=”latin” id=”content”> lorem ipsum </div> %div.latin#content lorem ipsum .latin#content lorem ipsum
  • 7. Example .posts <div class=”posts”> -@posts.count.each do |post| <% @posts.count.each do |post|%> %span.title= post.name <span class=”title”> %p= post.text <%= post.name %> </span> <p> <%= post.text %> </p> <% end %> </div>
  • 9. Basics .content padding: 5px margin-right: auto margin-left: auto img border: 1px solid black
  • 10. Nesting .h1 .h1 { font: font-weight: bold; weight: bold font-size: 1.2em; } size: 1.2em .h1 img { img margin: 5px; } margin: 5px
  • 11. Variables !margin = 10px h1 { !padding = 5px padding: 5px; !green = DarkGreen margin: 10px; !blue = DarkBlue color: DarkGreen; } h1 h2 { padding = !padding padding: 5px; margin = !margin margin: 10px; color = !green color: DarkBlue; } h2 padding = !padding margin = !margin color = !blue
  • 12. Mixins #data th { =table-scaffolding(!margin) text-align: center; th font-weight: bold; text-align: center } font-weight: bold #data td, #data th { td, th padding: 2px; padding: 2px margin: 10px; margin = !margin } #data +table-scaffolding(10px)
  • 13. Cool projects using Haml/Sass • StaticMatic - Adds the joy of dynamic websites to static ones • DynamicMatic - Adds a Sinatra back-end to StaticMatic
  • 14. Resources • haml-lang.com • sass-lang.com • html2haml / css2sass • Live rendering http://rendera.heroku.com/