SlideShare une entreprise Scribd logo
1  sur  16
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

Contenu connexe

Tendances

CSS Box Model and Dimensions
CSS Box Model and DimensionsCSS Box Model and Dimensions
CSS Box Model and DimensionsGerson Abesamis
 
Haml And Sass In 15 Minutes
Haml And Sass In 15 MinutesHaml And Sass In 15 Minutes
Haml And Sass In 15 MinutesPatrick Crowley
 
Basic HTML & CSS
Basic HTML & CSSBasic HTML & CSS
Basic HTML & CSSJohn Nelson
 
Haml And Sass: Put your markup on a diet
Haml And Sass: Put your markup on a dietHaml And Sass: Put your markup on a diet
Haml And Sass: Put your markup on a dietdavidsidlinger
 
Pemrograman Web 4 - Bootstrap 3
Pemrograman Web 4 - Bootstrap 3Pemrograman Web 4 - Bootstrap 3
Pemrograman Web 4 - Bootstrap 3Nur Fadli Utomo
 
From PSD to WordPress Theme: Bringing designs to life
From PSD to WordPress Theme: Bringing designs to lifeFrom PSD to WordPress Theme: Bringing designs to life
From PSD to WordPress Theme: Bringing designs to lifeDerek Christensen
 
Managing responsive websites with css preprocessors.
Managing responsive websites with css preprocessors. Managing responsive websites with css preprocessors.
Managing responsive websites with css preprocessors. The University of Akron
 
CSS Basics - Stylesheets and Color
CSS Basics - Stylesheets and ColorCSS Basics - Stylesheets and Color
CSS Basics - Stylesheets and ColorKelly Kellum
 
Web Design 101
Web Design 101Web Design 101
Web Design 101vegdwk
 
Cascading style sheet part 2
Cascading style sheet   part 2Cascading style sheet   part 2
Cascading style sheet part 2Himanshu Pathak
 
01 Introduction To CSS
01 Introduction To CSS01 Introduction To CSS
01 Introduction To CSScrgwbr
 
Drupal front-end performance
Drupal front-end performance Drupal front-end performance
Drupal front-end performance ADCI Solutions
 

Tendances (20)

Sass
SassSass
Sass
 
CSS Box Model and Dimensions
CSS Box Model and DimensionsCSS Box Model and Dimensions
CSS Box Model and Dimensions
 
Haml And Sass In 15 Minutes
Haml And Sass In 15 MinutesHaml And Sass In 15 Minutes
Haml And Sass In 15 Minutes
 
Basic HTML & CSS
Basic HTML & CSSBasic HTML & CSS
Basic HTML & CSS
 
Haml And Sass: Put your markup on a diet
Haml And Sass: Put your markup on a dietHaml And Sass: Put your markup on a diet
Haml And Sass: Put your markup on a diet
 
Pemrograman Web 4 - Bootstrap 3
Pemrograman Web 4 - Bootstrap 3Pemrograman Web 4 - Bootstrap 3
Pemrograman Web 4 - Bootstrap 3
 
From PSD to WordPress Theme: Bringing designs to life
From PSD to WordPress Theme: Bringing designs to lifeFrom PSD to WordPress Theme: Bringing designs to life
From PSD to WordPress Theme: Bringing designs to life
 
Php workshop L01 CSS
Php workshop L01 CSSPhp workshop L01 CSS
Php workshop L01 CSS
 
Managing responsive websites with css preprocessors.
Managing responsive websites with css preprocessors. Managing responsive websites with css preprocessors.
Managing responsive websites with css preprocessors.
 
CSS Basics - Stylesheets and Color
CSS Basics - Stylesheets and ColorCSS Basics - Stylesheets and Color
CSS Basics - Stylesheets and Color
 
Less css
Less cssLess css
Less css
 
Css frameworks
Css frameworksCss frameworks
Css frameworks
 
Web Design 101
Web Design 101Web Design 101
Web Design 101
 
Cascading style sheet part 2
Cascading style sheet   part 2Cascading style sheet   part 2
Cascading style sheet part 2
 
Intro to SASS CSS
Intro to SASS CSSIntro to SASS CSS
Intro to SASS CSS
 
Sass presentation
Sass presentationSass presentation
Sass presentation
 
01 Introduction To CSS
01 Introduction To CSS01 Introduction To CSS
01 Introduction To CSS
 
Artdm171 Week5 Css
Artdm171 Week5 CssArtdm171 Week5 Css
Artdm171 Week5 Css
 
CSS Reset
CSS ResetCSS Reset
CSS Reset
 
Drupal front-end performance
Drupal front-end performance Drupal front-end performance
Drupal front-end performance
 

En vedette

En vedette (6)

Our Adventure with MongoDB
Our Adventure with MongoDBOur Adventure with MongoDB
Our Adventure with MongoDB
 
Mongo chicago
Mongo chicagoMongo chicago
Mongo chicago
 
ActiveRecord is Rotting Your Brian
ActiveRecord is Rotting Your BrianActiveRecord is Rotting Your Brian
ActiveRecord is Rotting Your Brian
 
The ABCs of Scaling MongoDB
The ABCs of Scaling MongoDBThe ABCs of Scaling MongoDB
The ABCs of Scaling MongoDB
 
#IAEM November 2010
#IAEM November 2010#IAEM November 2010
#IAEM November 2010
 
On the Papers of Giants
On the Papers of GiantsOn the Papers of Giants
On the Papers of Giants
 

Similaire à Haml and Sass Introduction

Palestra pré processadores CSS
Palestra pré processadores CSSPalestra pré processadores CSS
Palestra pré processadores CSSJust Digital
 
Rapid Prototyping
Rapid PrototypingRapid Prototyping
Rapid PrototypingEven Wu
 
CSSプリプロセッサの取扱説明書
CSSプリプロセッサの取扱説明書CSSプリプロセッサの取扱説明書
CSSプリプロセッサの取扱説明書拓樹 谷
 
Compass And Sass(Tim Riley)
Compass And Sass(Tim Riley)Compass And Sass(Tim Riley)
Compass And Sass(Tim Riley)elliando dias
 
Web Design Bootcamp - Day1
Web Design Bootcamp - Day1Web Design Bootcamp - Day1
Web Design Bootcamp - Day1Aslam Najeebdeen
 
Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)emrox
 
Fasten RWD Development with Sass
Fasten RWD Development with SassFasten RWD Development with Sass
Fasten RWD Development with SassSven Wolfermann
 
Supercharged HTML & CSS
Supercharged HTML & CSSSupercharged HTML & CSS
Supercharged HTML & CSSMax Kraszewski
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008tutorialsruby
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008tutorialsruby
 

Similaire à Haml and Sass Introduction (20)

Palestra pré processadores CSS
Palestra pré processadores CSSPalestra pré processadores CSS
Palestra pré processadores CSS
 
Pemrograman Web 2 - CSS
Pemrograman Web 2 - CSSPemrograman Web 2 - CSS
Pemrograman Web 2 - CSS
 
Rapid Prototyping
Rapid PrototypingRapid Prototyping
Rapid Prototyping
 
CSSプリプロセッサの取扱説明書
CSSプリプロセッサの取扱説明書CSSプリプロセッサの取扱説明書
CSSプリプロセッサの取扱説明書
 
Compass And Sass(Tim Riley)
Compass And Sass(Tim Riley)Compass And Sass(Tim Riley)
Compass And Sass(Tim Riley)
 
Web Design Bootcamp - Day1
Web Design Bootcamp - Day1Web Design Bootcamp - Day1
Web Design Bootcamp - Day1
 
Accelerated Stylesheets
Accelerated StylesheetsAccelerated Stylesheets
Accelerated Stylesheets
 
Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)
 
Fasten RWD Development with Sass
Fasten RWD Development with SassFasten RWD Development with Sass
Fasten RWD Development with Sass
 
Css tips & tricks
Css tips & tricksCss tips & tricks
Css tips & tricks
 
Supercharged HTML & CSS
Supercharged HTML & CSSSupercharged HTML & CSS
Supercharged HTML & CSS
 
Css
CssCss
Css
 
Css
CssCss
Css
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
 
Css1
Css1Css1
Css1
 
Sass compass
Sass compassSass compass
Sass compass
 
ARTDM 171, Week 5: CSS
ARTDM 171, Week 5: CSSARTDM 171, Week 5: CSS
ARTDM 171, Week 5: CSS
 
CSS
CSSCSS
CSS
 
Intro to CSS
Intro to CSSIntro to CSS
Intro to CSS
 

Dernier

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 

Dernier (20)

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 

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/