SlideShare a Scribd company logo
Haml
http://haml.hamptoncatlin.com/
What is Haml?

• A markup language
• An alternative to erb / RHTML for Rails +
  Merb
• rubygem or rails plugin
Haml has principles

           • Markup should be beautiful
           • Markup should be DRY
           • Markup should be well-indented
           • XHTML structure should be clear


Beautiful - READABLE!
DRY - in XHTML elements are named twice, ERB adds even more repetition. HAML relies on
indentation to determine where elements and blocks of code begin and end-> smaller templates +
cleaner code
well indented - ERB doesn’t encourage well-indented code. Haml indents properly all the time
XHTML structure should be clear - guaranteed by the first 3
Syntax


                  %tag content                   <tag>content</tag>




The percent character is placed at the beginning of a line. It’s followed immediately by the name of
an element, then the text to be rendered inside the element
Syntax

                                          <h1>Haml should be</h1>
  %h1 Haml should be
                                          <ul>
  %ul
                                            <li>Beautiful</li>
    %li Beautiful
                                            <li>DRY</li>
    %li DRY
                                            <li>Well-indented</li>
    %li Well-indented
                                          </ul>




nesting is achieved through indentation
Attributes

                                                      <p class='bio'>
 %p{:class => quot;bioquot;}
                                                        This paragraph has class
   This paragraph has class
                                                      </p>
                                                      <p id='bio'>
 %p{:id => quot;bioquot;}
                                                        This paragraph has identity
   This paragraph has identity
                                                      </p>




A Ruby hash is used for specifying the attributes of an element. It is literally evaluated as a Ruby
hash, so logic will work in it and local variables may be used
A Ruby method call that returns a hash can be substituted for the hash contents
multiple hashes, separated by commas can be used
class and id shortcuts

                                 <p class='bio'>
 %p.bio
                                   This paragraph has class
   This paragraph has class
                                 </p>
                                 <p id='bio'>
 %p#bio
                                   This paragraph has identity
   This paragraph has identity
                                 </p>




borrowed from CSS
Implicit <div>

                                                          <div class='class'>
                                                            <div id='id'>
    .class                                                    <p>
      #id                                                        I'm wrapped in two divs
        %p                                                    </p>
           I'm wrapped in two divs                          </div>
                                                          </div>




If you only define a class and/or id using the . or # syntax, a div element is automatically used
Haml -vs- HTML
!!!                                         <!DOCTYPE html PUBLIC quot;-//W3C//DTD XHTML 1.0
%html{ html_attrs }                         Transitional//ENquot; quot;http://www.w3.org/TR/
  %head                                     xhtml1/DTD/xhtml1-transitional.dtdquot;>
    %title Haml syntax demo                 <html lang='en-US' xml:lang='en-US'
  %body                                     xmlns='http://www.w3.org/1999/xhtml'>
    #content                                  <head>
      %h1 Haml should be:                       <title>Haml syntax demo</title>
      %ul.principles                          </head>
        %li Beautiful                         <body>
        %li DRY                                 <div id='content'>
        %li Well-indented                         <h1>Haml should be:</h1>
        %li Clearly XHTML                         <ul class='principles'>
    #footer                                          <li>Beautiful</li>
      %span.author Ciaran                            <li>DRY</li>
                                                     <li>Well-indented</li>
                                                     <li>Clearly XHTML</li>
                                                  </ul>
                                                </div>
                                                <div id='footer'>
                                                  <span class='author'>Ciaran</span>
                                                </div>
                                              </body>
                                            </html>

!!! generates doctype
!!! XML generates XML prolog
html_attrs is a Haml Helper, Returns a hash containing default assignments for the xmlns and
xml:lang attributes of the html HTML element
Ruby evaluators
          - for article in @articles
            .post
              .date
                %h3= h article.publication_date.strftime(quot;%d %m %Yquot;)
              .article
                %h3= link_to(h(article.title), article)
                ~article.body




= is followed by Ruby code, which is evaluated and the output inserted into the document as plain
text
- hyphen character makes the text following it into quot;silent scriptquot;: Ruby script that is evaluated, but
not output
for loop (+ all Ruby blocks) are automatically closed, based on indentation
~ acts like = except that it preserves the whitespace
Haml in rails projects




rails 2.0 uses $view.html.erb , for haml views just replace erb with haml
Resources


• http://haml.hamptoncatlin.com
• http://lab.hamptoncatlin.com/play/with/haml
SASS


• Syntactically Awesome StyleSheets
• comes with haml
SASS syntax

       #main p
                                                              #main p {
         :color #00ff00
                                                                color: #00ff00;
         :width 97%
                                                                width: 97%; }
                                                                #main p .redbox {
         .redbox
                                                                  background-color: #ff0000;
           :background-color #ff0000
                                                                  color: #000000; }
           :color #000000




Rules can also be nested within each other. This signifies that the inner rule’s selector is a child of
the outer selector
SASS Constants

  !main_color = #00ff00
                                                      #main {
  #main                                                 color: #00ff00; }
    :color = !main_color                                #main p {
    :p                                                    background-color: #00ff00;
       :background-color = !main_color                    color: #000000; }
       :color #000000




support for setting document-wide constants. They‘re set using an exclamation mark followed by
the name, an equals sign, and the value
make_resourceful


           • rails plugin
           • DRYs up controller code
           • http://railscasts.com/episodes/92


Show some code, it’s cool, but depending on how much customisation you do it might be better to
use the standard RESTful controller

More Related Content

Similar to Haml

Introdução a CSS
Introdução a CSS Introdução a CSS
Introdução a CSS
Tiago Santos
 
Hows Haml?
Hows Haml?Hows Haml?
Hows Haml?
Patrick Reagan
 
CSS Layout Tutorial
CSS Layout TutorialCSS Layout Tutorial
CSS Layout Tutorial
hstryk
 
How to create a basic template
How to create a basic templateHow to create a basic template
How to create a basic template
vathur
 
Php
PhpPhp
DRYing Up Rails Views and Controllers
DRYing Up Rails Views and ControllersDRYing Up Rails Views and Controllers
DRYing Up Rails Views and Controllers
James Gray
 
Haml. New HTML? (RU)
Haml. New HTML? (RU)Haml. New HTML? (RU)
Haml. New HTML? (RU)
Kirill Zonov
 
Building the basics (WordPress Ottawa 2014)
Building the basics (WordPress Ottawa 2014)Building the basics (WordPress Ottawa 2014)
Building the basics (WordPress Ottawa 2014)
Christopher Ross
 
Presentation.Key
Presentation.KeyPresentation.Key
Presentation.Key
guesta2b31d
 
Prototyping With Haml & Sass
Prototyping With Haml & SassPrototyping With Haml & Sass
Prototyping With Haml & Sass
amwatts
 
Haml in 5 minutes
Haml in 5 minutesHaml in 5 minutes
Haml in 5 minutes
cameronbot
 
Beyond HTML - Scriptsprachen, Frameworks, Templatesprachen und vieles mehr
Beyond HTML - Scriptsprachen, Frameworks, Templatesprachen und vieles mehrBeyond HTML - Scriptsprachen, Frameworks, Templatesprachen und vieles mehr
Beyond HTML - Scriptsprachen, Frameworks, Templatesprachen und vieles mehr
Jens-Christian Fischer
 
Grok Drupal (7) Theming - 2011 Feb update
Grok Drupal (7) Theming - 2011 Feb updateGrok Drupal (7) Theming - 2011 Feb update
Grok Drupal (7) Theming - 2011 Feb update
Laura Scott
 
Html xhtml tag-sheet
Html xhtml tag-sheetHtml xhtml tag-sheet
Html xhtml tag-sheet
wihrbt
 
Lesson 3
Lesson 3Lesson 3
Lesson 3
hstryk
 
Css
CssCss
Css
CssCss
Html / CSS Presentation
Html / CSS PresentationHtml / CSS Presentation
Html / CSS Presentation
Shawn Calvert
 
Documenting from the Trenches
Documenting from the TrenchesDocumenting from the Trenches
Documenting from the Trenches
Xavier Noria
 
Web Typography
Web TypographyWeb Typography
Web Typography
Shawn Calvert
 

Similar to Haml (20)

Introdução a CSS
Introdução a CSS Introdução a CSS
Introdução a CSS
 
Hows Haml?
Hows Haml?Hows Haml?
Hows Haml?
 
CSS Layout Tutorial
CSS Layout TutorialCSS Layout Tutorial
CSS Layout Tutorial
 
How to create a basic template
How to create a basic templateHow to create a basic template
How to create a basic template
 
Php
PhpPhp
Php
 
DRYing Up Rails Views and Controllers
DRYing Up Rails Views and ControllersDRYing Up Rails Views and Controllers
DRYing Up Rails Views and Controllers
 
Haml. New HTML? (RU)
Haml. New HTML? (RU)Haml. New HTML? (RU)
Haml. New HTML? (RU)
 
Building the basics (WordPress Ottawa 2014)
Building the basics (WordPress Ottawa 2014)Building the basics (WordPress Ottawa 2014)
Building the basics (WordPress Ottawa 2014)
 
Presentation.Key
Presentation.KeyPresentation.Key
Presentation.Key
 
Prototyping With Haml & Sass
Prototyping With Haml & SassPrototyping With Haml & Sass
Prototyping With Haml & Sass
 
Haml in 5 minutes
Haml in 5 minutesHaml in 5 minutes
Haml in 5 minutes
 
Beyond HTML - Scriptsprachen, Frameworks, Templatesprachen und vieles mehr
Beyond HTML - Scriptsprachen, Frameworks, Templatesprachen und vieles mehrBeyond HTML - Scriptsprachen, Frameworks, Templatesprachen und vieles mehr
Beyond HTML - Scriptsprachen, Frameworks, Templatesprachen und vieles mehr
 
Grok Drupal (7) Theming - 2011 Feb update
Grok Drupal (7) Theming - 2011 Feb updateGrok Drupal (7) Theming - 2011 Feb update
Grok Drupal (7) Theming - 2011 Feb update
 
Html xhtml tag-sheet
Html xhtml tag-sheetHtml xhtml tag-sheet
Html xhtml tag-sheet
 
Lesson 3
Lesson 3Lesson 3
Lesson 3
 
Css
CssCss
Css
 
Css
CssCss
Css
 
Html / CSS Presentation
Html / CSS PresentationHtml / CSS Presentation
Html / CSS Presentation
 
Documenting from the Trenches
Documenting from the TrenchesDocumenting from the Trenches
Documenting from the Trenches
 
Web Typography
Web TypographyWeb Typography
Web Typography
 

Recently uploaded

Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Project Management Semester Long Project - Acuity
Project Management Semester Long Project - AcuityProject Management Semester Long Project - Acuity
Project Management Semester Long Project - Acuity
jpupo2018
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 

Recently uploaded (20)

Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Project Management Semester Long Project - Acuity
Project Management Semester Long Project - AcuityProject Management Semester Long Project - Acuity
Project Management Semester Long Project - Acuity
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 

Haml

  • 2. What is Haml? • A markup language • An alternative to erb / RHTML for Rails + Merb • rubygem or rails plugin
  • 3. Haml has principles • Markup should be beautiful • Markup should be DRY • Markup should be well-indented • XHTML structure should be clear Beautiful - READABLE! DRY - in XHTML elements are named twice, ERB adds even more repetition. HAML relies on indentation to determine where elements and blocks of code begin and end-> smaller templates + cleaner code well indented - ERB doesn’t encourage well-indented code. Haml indents properly all the time XHTML structure should be clear - guaranteed by the first 3
  • 4. Syntax %tag content <tag>content</tag> The percent character is placed at the beginning of a line. It’s followed immediately by the name of an element, then the text to be rendered inside the element
  • 5. Syntax <h1>Haml should be</h1> %h1 Haml should be <ul> %ul <li>Beautiful</li> %li Beautiful <li>DRY</li> %li DRY <li>Well-indented</li> %li Well-indented </ul> nesting is achieved through indentation
  • 6. Attributes <p class='bio'> %p{:class => quot;bioquot;} This paragraph has class This paragraph has class </p> <p id='bio'> %p{:id => quot;bioquot;} This paragraph has identity This paragraph has identity </p> A Ruby hash is used for specifying the attributes of an element. It is literally evaluated as a Ruby hash, so logic will work in it and local variables may be used A Ruby method call that returns a hash can be substituted for the hash contents multiple hashes, separated by commas can be used
  • 7. class and id shortcuts <p class='bio'> %p.bio This paragraph has class This paragraph has class </p> <p id='bio'> %p#bio This paragraph has identity This paragraph has identity </p> borrowed from CSS
  • 8. Implicit <div> <div class='class'> <div id='id'> .class <p> #id I'm wrapped in two divs %p </p> I'm wrapped in two divs </div> </div> If you only define a class and/or id using the . or # syntax, a div element is automatically used
  • 9. Haml -vs- HTML !!! <!DOCTYPE html PUBLIC quot;-//W3C//DTD XHTML 1.0 %html{ html_attrs } Transitional//ENquot; quot;http://www.w3.org/TR/ %head xhtml1/DTD/xhtml1-transitional.dtdquot;> %title Haml syntax demo <html lang='en-US' xml:lang='en-US' %body xmlns='http://www.w3.org/1999/xhtml'> #content <head> %h1 Haml should be: <title>Haml syntax demo</title> %ul.principles </head> %li Beautiful <body> %li DRY <div id='content'> %li Well-indented <h1>Haml should be:</h1> %li Clearly XHTML <ul class='principles'> #footer <li>Beautiful</li> %span.author Ciaran <li>DRY</li> <li>Well-indented</li> <li>Clearly XHTML</li> </ul> </div> <div id='footer'> <span class='author'>Ciaran</span> </div> </body> </html> !!! generates doctype !!! XML generates XML prolog html_attrs is a Haml Helper, Returns a hash containing default assignments for the xmlns and xml:lang attributes of the html HTML element
  • 10. Ruby evaluators - for article in @articles .post .date %h3= h article.publication_date.strftime(quot;%d %m %Yquot;) .article %h3= link_to(h(article.title), article) ~article.body = is followed by Ruby code, which is evaluated and the output inserted into the document as plain text - hyphen character makes the text following it into quot;silent scriptquot;: Ruby script that is evaluated, but not output for loop (+ all Ruby blocks) are automatically closed, based on indentation ~ acts like = except that it preserves the whitespace
  • 11. Haml in rails projects rails 2.0 uses $view.html.erb , for haml views just replace erb with haml
  • 13. SASS • Syntactically Awesome StyleSheets • comes with haml
  • 14. SASS syntax #main p #main p { :color #00ff00 color: #00ff00; :width 97% width: 97%; } #main p .redbox { .redbox background-color: #ff0000; :background-color #ff0000 color: #000000; } :color #000000 Rules can also be nested within each other. This signifies that the inner rule’s selector is a child of the outer selector
  • 15. SASS Constants !main_color = #00ff00 #main { #main color: #00ff00; } :color = !main_color #main p { :p background-color: #00ff00; :background-color = !main_color color: #000000; } :color #000000 support for setting document-wide constants. They‘re set using an exclamation mark followed by the name, an equals sign, and the value
  • 16. make_resourceful • rails plugin • DRYs up controller code • http://railscasts.com/episodes/92 Show some code, it’s cool, but depending on how much customisation you do it might be better to use the standard RESTful controller