SlideShare a Scribd company logo
1 of 23
Download to read offline
How’s Haml?
Patrick Reagan
What is Haml?

• Templating language for creating XHTML
• Alternative to ERB in Rails
• Principle: “Markup should be beautiful”
What is Beauty?
What is Beauty?
Installation
$ sudo gem install --no-ri haml
Successfully installed haml-1.8.0
1 gem installed
Installing RDoc documentation for haml-1.8.0...




$ haml --rails ./my_rails_app
Haml plugin added to ./my_rails_app
Using Haml
 Rename views and layouts

app/views/posts: index.html.erb => index.html.haml
app/views/layouts: application.html.erb => application.haml




  Start deleting!
ERB / RHTML
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang='en-US' xml:lang='en-US' xmlns='http://www.w3.org/1999/xhtml'>
  <head>
    <title>Yet Another Rails Blog</title>
  </head>
  <body>
    <div id='container'>
      <div id='navigation'>
        <%= link_to 'Home', root_path %>
      </div>
      <div id='content'>
        <% @posts.each do |post| -%>
         <div class='post'>
           <h3><%= h post.title %></h3>
           <strong>by: <%= post.author %></strong>
           <p><%= post.body %></p>
         </div>
        <% end %>
      </div>
    </div>
  </body>
</html>
ERB / RHTML
<?xml version='1.0' encoding='utf-8' ?>
!!! XML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
!!! Strict
%html{html_attrs}      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang='en-US' xml:lang='en-US' xmlns='http://www.w3.org/1999/xhtml'>
  <head>
    <title>Yet Another Rails Blog</title>
  </head>
  <body>
    <div id='container'>
      <div id='navigation'>
        <%= link_to 'Home', root_path %>
      </div>
      <div id='content'>
        <% @posts.each do |post| -%>
         <div class='post'>
           <h3><%= h post.title %></h3>
           <strong>by: <%= post.author %></strong>
           <p><%= post.body %></p>
         </div>
        <% end %>
      </div>
    </div>
  </body>
</html>
ERB / RHTML
<?xml version='1.0' encoding='utf-8' ?>
!!! XML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
!!! Strict
%html{html_attrs}      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang='en-US' xml:lang='en-US' xmlns='http://www.w3.org/1999/xhtml'>
  %head
  <head>
    %title Yet Another Rails Blog
    <title>Yet Another Rails Blog</title>
  %body
  </head>
  <body>
    <div id='container'>
      <div id='navigation'>
        <%= link_to 'Home', root_path %>
      </div>
      <div id='content'>
        <% @posts.each do |post| -%>
         <div class='post'>
           <h3><%= h post.title %></h3>
           <strong>by: <%= post.author %></strong>
           <p><%= post.body %></p>
         </div>
        <% end %>
      </div>
    </div>
  </body>
</html>
ERB / RHTML
<?xml version='1.0' encoding='utf-8' ?>
!!! XML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
!!! Strict
%html{html_attrs}      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang='en-US' xml:lang='en-US' xmlns='http://www.w3.org/1999/xhtml'>
  %head
  <head>
    %title Yet Another Rails Blog
    <title>Yet Another Rails Blog</title>
  %body
  </head>
  <body>
    #container
    <div id='container'>
      #navigation
      <div id='navigation'>
         = link_to('Home', root_path)
        <%= link_to 'Home', root_path %>
      </div>
      <div id='content'>
        <% @posts.each do |post| -%>
         <div class='post'>
           <h3><%= h post.title %></h3>
           <strong>by: <%= post.author %></strong>
           <p><%= post.body %></p>
         </div>
        <% end %>
      </div>
    </div>
  </body>
</html>
Hamlified!
<?xml version='1.0' encoding='utf-8' ?>
!!! XML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
!!! Strict
%html{html_attrs}      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang='en-US' xml:lang='en-US' xmlns='http://www.w3.org/1999/xhtml'>
  %head
  <head>
    %title Yet Another Rails Blog
    <title>Yet Another Rails Blog</title>
  %body
  </head>
  <body>
    #container
    <div id='container'>
      #navigation
      <div id='navigation'>
         = link_to('Home', root_path)
        <%= link_to 'Home', root_path %>
      </div>
      #content
      <div id='content'>
        <%@posts.each do |post| -%>
         - @posts.each do |post|
           .post
         <div class='post'>
           <h3><%=h(post.title) %></h3>
             %h3= h post.title
           <strong>by:"by: post.author %></strong>
             %strong= <%= #{h(post.author)}"
           <p><%=post.body %></p>
             %p= post.body
         </div>
        <% end %>
      </div>
    </div>
  </body>
</html>
Haml Deconstructed
    !!! XML
    !!! Strict

    %html{html_attrs}
      %head
        %title Yet Another Rails Blog
      %body
        #container
          #navigation
            = link_to('Home', root_path)
          #content
            - @posts.each do |post|
              .post
                %h3= h(post.title)
                %strong= "by: #{h(post.author)}"
                %p= post.body
Haml Deconstructed
XHTML document type
                      !!! XML
                      !!! Strict

                      %html{html_attrs}
                        %head
                          %title Yet Another Rails Blog
                        %body
                          #container
                            #navigation
                              = link_to('Home', root_path)
                            #content
                              - @posts.each do |post|
                                .post
                                  %h3= h(post.title)
                                  %strong= "by: #{h(post.author)}"
                                  %p= post.body
Haml Deconstructed
XHTML document type
                      !!! XML
  XHTML tag with      !!! Strict

   static content     %html{html_attrs}
                        %head
                          %title Yet Another Rails Blog
                        %body
                          #container
                            #navigation
                              = link_to('Home', root_path)
                            #content
                              - @posts.each do |post|
                                .post
                                  %h3= h(post.title)
                                  %strong= "by: #{h(post.author)}"
                                  %p= post.body
Haml Deconstructed
XHTML document type                    Haml helper method
                      !!! XML
  XHTML tag with      !!! Strict

   static content     %html{html_attrs}
                        %head
                          %title Yet Another Rails Blog
                        %body
                          #container
                            #navigation
                              = link_to('Home', root_path)
                            #content
                              - @posts.each do |post|
                                .post
                                  %h3= h(post.title)
                                  %strong= "by: #{h(post.author)}"
                                  %p= post.body
Haml Deconstructed
XHTML document type                    Haml helper method
                      !!! XML
  XHTML tag with      !!! Strict

   static content     %html{html_attrs}
                        %head
                          %title Yet Another Rails Blog
   DIV tag with ID      %body
                          #container
                            #navigation
                              = link_to('Home', root_path)
                            #content
                              - @posts.each do |post|
                                .post
                                  %h3= h(post.title)
                                  %strong= "by: #{h(post.author)}"
                                  %p= post.body
Haml Deconstructed
XHTML document type                    Haml helper method
                      !!! XML
  XHTML tag with      !!! Strict

   static content     %html{html_attrs}
                        %head
                          %title Yet Another Rails Blog
   DIV tag with ID      %body
                          #container
                            #navigation
                              = link_to('Home', root_path)
 Execute Ruby code          #content
                              - @posts.each do |post|
                                .post
                                  %h3= h(post.title)
                                  %strong= "by: #{h(post.author)}"
                                  %p= post.body
Haml Deconstructed
XHTML document type                    Haml helper method
                      !!! XML
  XHTML tag with      !!! Strict

   static content     %html{html_attrs}
                        %head
                          %title Yet Another Rails Blog
   DIV tag with ID      %body
                          #container
                            #navigation
                              = link_to('Home', root_path)
 Execute Ruby code          #content
                              - @posts.each do |post|
                                .post
                                  %h3= h(post.title)
  XHTML tag with                  %strong= "by: #{h(post.author)}"
                                  %p= post.body
  dynamic content
XHTML Output
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang='en-US' xml:lang='en-US' xmlns='http://www.w3.org/1999/xhtml'>
  <head>
    <title>Yet Another Rails Blog</title>
  </head>
  <body>
    <div id='container'>
      <div id='navigation'>
         <a href="/">Home</a>
      </div>
      <div id='content'>
         <div class='post'>
           <h3>January Refresh Recap</h3>
           <strong>by: Patrick</strong>
           <p>It was awesome!</p>
         </div>

        ...

      </div>
    </div>
  </body>
</html>
Off the Rails?

$ irb
>> require 'rubygems'
=> true
>> require 'haml'
=> true
>> Haml::Engine.new('%p Hello, World').render
=> "<p>Hello, World</p>n"
Why Use It?

• Creates well-formatted markup
• Automatic closing of tags
• Less “noise”
Why Not?

• Buildout must happen inside Rails
• XHTML is a widespread standard
• Performance
Resources
Other templating systems
 •   Erubis
 •   Markaby
 •   pHAML

Tutorial & Documentation
 •   http://haml.hamptoncatlin.com/tutorial/
 •   http://haml.hamptoncatlin.com/docs/

TextMate Bundle (via SVN)
 •   http://macromates.com/svn/Bundles/trunk

More Related Content

What's hot

Comprehensive Browser Automation Solution using Groovy, WebDriver & Obect Model
Comprehensive Browser Automation Solution using Groovy, WebDriver & Obect ModelComprehensive Browser Automation Solution using Groovy, WebDriver & Obect Model
Comprehensive Browser Automation Solution using Groovy, WebDriver & Obect ModelvodQA
 
Theme Kickstart
Theme KickstartTheme Kickstart
Theme KickstartPeter
 
11 page-directive
11 page-directive11 page-directive
11 page-directivesnopteck
 
RESTful Web Services
RESTful Web ServicesRESTful Web Services
RESTful Web ServicesGreg Hines
 
Amp and higher computing science
Amp and higher computing scienceAmp and higher computing science
Amp and higher computing scienceCharlie Love
 
Killing the Angle Bracket
Killing the Angle BracketKilling the Angle Bracket
Killing the Angle Bracketjnewmanux
 
Layouts and Rendering in Rails, Season 2
Layouts and Rendering in Rails, Season 2Layouts and Rendering in Rails, Season 2
Layouts and Rendering in Rails, Season 2RORLAB
 

What's hot (12)

Comprehensive Browser Automation Solution using Groovy, WebDriver & Obect Model
Comprehensive Browser Automation Solution using Groovy, WebDriver & Obect ModelComprehensive Browser Automation Solution using Groovy, WebDriver & Obect Model
Comprehensive Browser Automation Solution using Groovy, WebDriver & Obect Model
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScript
 
Theme Kickstart
Theme KickstartTheme Kickstart
Theme Kickstart
 
11 page-directive
11 page-directive11 page-directive
11 page-directive
 
RESTful Web Services
RESTful Web ServicesRESTful Web Services
RESTful Web Services
 
Rails 4.0
Rails 4.0Rails 4.0
Rails 4.0
 
Amp and higher computing science
Amp and higher computing scienceAmp and higher computing science
Amp and higher computing science
 
HTML 5 & CSS 3
HTML 5 & CSS 3HTML 5 & CSS 3
HTML 5 & CSS 3
 
Killing the Angle Bracket
Killing the Angle BracketKilling the Angle Bracket
Killing the Angle Bracket
 
HTML5 Essentials
HTML5 EssentialsHTML5 Essentials
HTML5 Essentials
 
Workshop 6: Designer tools
Workshop 6: Designer toolsWorkshop 6: Designer tools
Workshop 6: Designer tools
 
Layouts and Rendering in Rails, Season 2
Layouts and Rendering in Rails, Season 2Layouts and Rendering in Rails, Season 2
Layouts and Rendering in Rails, Season 2
 

Viewers also liked

Coding With Confidence: Adding TDD to Your Toolset
Coding With Confidence: Adding TDD to Your ToolsetCoding With Confidence: Adding TDD to Your Toolset
Coding With Confidence: Adding TDD to Your ToolsetPatrick Reagan
 
Mockfight! FlexMock vs. Mocha
Mockfight! FlexMock vs. MochaMockfight! FlexMock vs. Mocha
Mockfight! FlexMock vs. MochaPatrick Reagan
 
Changing Your Mindset: Getting Started with Test-Driven Development
Changing Your Mindset: Getting Started with Test-Driven DevelopmentChanging Your Mindset: Getting Started with Test-Driven Development
Changing Your Mindset: Getting Started with Test-Driven DevelopmentPatrick Reagan
 
Make Everyone a Tester: Natural Language Acceptance Testing
Make Everyone a Tester: Natural Language Acceptance TestingMake Everyone a Tester: Natural Language Acceptance Testing
Make Everyone a Tester: Natural Language Acceptance TestingPatrick Reagan
 
Better Functional Design through TDD
Better Functional Design through TDDBetter Functional Design through TDD
Better Functional Design through TDDPhil Calçado
 
32 Ways a Digital Marketing Consultant Can Help Grow Your Business
32 Ways a Digital Marketing Consultant Can Help Grow Your Business32 Ways a Digital Marketing Consultant Can Help Grow Your Business
32 Ways a Digital Marketing Consultant Can Help Grow Your BusinessBarry Feldman
 

Viewers also liked (6)

Coding With Confidence: Adding TDD to Your Toolset
Coding With Confidence: Adding TDD to Your ToolsetCoding With Confidence: Adding TDD to Your Toolset
Coding With Confidence: Adding TDD to Your Toolset
 
Mockfight! FlexMock vs. Mocha
Mockfight! FlexMock vs. MochaMockfight! FlexMock vs. Mocha
Mockfight! FlexMock vs. Mocha
 
Changing Your Mindset: Getting Started with Test-Driven Development
Changing Your Mindset: Getting Started with Test-Driven DevelopmentChanging Your Mindset: Getting Started with Test-Driven Development
Changing Your Mindset: Getting Started with Test-Driven Development
 
Make Everyone a Tester: Natural Language Acceptance Testing
Make Everyone a Tester: Natural Language Acceptance TestingMake Everyone a Tester: Natural Language Acceptance Testing
Make Everyone a Tester: Natural Language Acceptance Testing
 
Better Functional Design through TDD
Better Functional Design through TDDBetter Functional Design through TDD
Better Functional Design through TDD
 
32 Ways a Digital Marketing Consultant Can Help Grow Your Business
32 Ways a Digital Marketing Consultant Can Help Grow Your Business32 Ways a Digital Marketing Consultant Can Help Grow Your Business
32 Ways a Digital Marketing Consultant Can Help Grow Your Business
 

Similar to Hows Haml?

How to create a basic template
How to create a basic templateHow to create a basic template
How to create a basic templatevathur
 
Zen codingcheatsheet
Zen codingcheatsheetZen codingcheatsheet
Zen codingcheatsheetgoldenveizer
 
Statische Websites in Rails 3.1
Statische Websites in Rails 3.1Statische Websites in Rails 3.1
Statische Websites in Rails 3.1RobinBrouwer
 
Simple Markdown with Ecto and Protocols
Simple Markdown with Ecto and ProtocolsSimple Markdown with Ecto and Protocols
Simple Markdown with Ecto and ProtocolsDavid Lucia
 
Django Templates
Django TemplatesDjango Templates
Django TemplatesWilly Liu
 
Noticias Ducez
Noticias DucezNoticias Ducez
Noticias Ducezmatheus
 
Introduction to xhtml
Introduction to xhtmlIntroduction to xhtml
Introduction to xhtmlDhairya Joshi
 
Getting to know perch — and perch runway!
Getting to know perch — and perch runway!Getting to know perch — and perch runway!
Getting to know perch — and perch runway!Abigail Larsen
 
AttributesL3.pptx
AttributesL3.pptxAttributesL3.pptx
AttributesL3.pptxKrishRaj48
 
WDIM268 Week 6 (Summer 2010)
WDIM268 Week 6 (Summer 2010)WDIM268 Week 6 (Summer 2010)
WDIM268 Week 6 (Summer 2010)Tyler Sticka
 
Introdução a CSS
Introdução a CSS Introdução a CSS
Introdução a CSS Tiago Santos
 
Html goodies
Html goodiesHtml goodies
Html goodiesAli Hasan
 

Similar to Hows Haml? (20)

Haml
HamlHaml
Haml
 
How to create a basic template
How to create a basic templateHow to create a basic template
How to create a basic template
 
Zen codingcheatsheet
Zen codingcheatsheetZen codingcheatsheet
Zen codingcheatsheet
 
Statische Websites in Rails 3.1
Statische Websites in Rails 3.1Statische Websites in Rails 3.1
Statische Websites in Rails 3.1
 
Simple Markdown with Ecto and Protocols
Simple Markdown with Ecto and ProtocolsSimple Markdown with Ecto and Protocols
Simple Markdown with Ecto and Protocols
 
Lecture1and2
Lecture1and2Lecture1and2
Lecture1and2
 
Django Templates
Django TemplatesDjango Templates
Django Templates
 
Html.docx
Html.docxHtml.docx
Html.docx
 
Noticias Ducez
Noticias DucezNoticias Ducez
Noticias Ducez
 
Introduction to xhtml
Introduction to xhtmlIntroduction to xhtml
Introduction to xhtml
 
Frfrfrf
FrfrfrfFrfrfrf
Frfrfrf
 
Html Workshop
Html WorkshopHtml Workshop
Html Workshop
 
Getting to know perch — and perch runway!
Getting to know perch — and perch runway!Getting to know perch — and perch runway!
Getting to know perch — and perch runway!
 
AttributesL3.pptx
AttributesL3.pptxAttributesL3.pptx
AttributesL3.pptx
 
WDIM268 Week 6 (Summer 2010)
WDIM268 Week 6 (Summer 2010)WDIM268 Week 6 (Summer 2010)
WDIM268 Week 6 (Summer 2010)
 
Introdução a CSS
Introdução a CSS Introdução a CSS
Introdução a CSS
 
Html full
Html fullHtml full
Html full
 
Java script and html new
Java script and html newJava script and html new
Java script and html new
 
Java script and html
Java script and htmlJava script and html
Java script and html
 
Html goodies
Html goodiesHtml goodies
Html goodies
 

Recently uploaded

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
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
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

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
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
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
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

Hows Haml?

  • 2. What is Haml? • Templating language for creating XHTML • Alternative to ERB in Rails • Principle: “Markup should be beautiful”
  • 5. Installation $ sudo gem install --no-ri haml Successfully installed haml-1.8.0 1 gem installed Installing RDoc documentation for haml-1.8.0... $ haml --rails ./my_rails_app Haml plugin added to ./my_rails_app
  • 6. Using Haml Rename views and layouts app/views/posts: index.html.erb => index.html.haml app/views/layouts: application.html.erb => application.haml Start deleting!
  • 7. ERB / RHTML <?xml version='1.0' encoding='utf-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang='en-US' xml:lang='en-US' xmlns='http://www.w3.org/1999/xhtml'> <head> <title>Yet Another Rails Blog</title> </head> <body> <div id='container'> <div id='navigation'> <%= link_to 'Home', root_path %> </div> <div id='content'> <% @posts.each do |post| -%> <div class='post'> <h3><%= h post.title %></h3> <strong>by: <%= post.author %></strong> <p><%= post.body %></p> </div> <% end %> </div> </div> </body> </html>
  • 8. ERB / RHTML <?xml version='1.0' encoding='utf-8' ?> !!! XML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" !!! Strict %html{html_attrs} "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang='en-US' xml:lang='en-US' xmlns='http://www.w3.org/1999/xhtml'> <head> <title>Yet Another Rails Blog</title> </head> <body> <div id='container'> <div id='navigation'> <%= link_to 'Home', root_path %> </div> <div id='content'> <% @posts.each do |post| -%> <div class='post'> <h3><%= h post.title %></h3> <strong>by: <%= post.author %></strong> <p><%= post.body %></p> </div> <% end %> </div> </div> </body> </html>
  • 9. ERB / RHTML <?xml version='1.0' encoding='utf-8' ?> !!! XML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" !!! Strict %html{html_attrs} "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang='en-US' xml:lang='en-US' xmlns='http://www.w3.org/1999/xhtml'> %head <head> %title Yet Another Rails Blog <title>Yet Another Rails Blog</title> %body </head> <body> <div id='container'> <div id='navigation'> <%= link_to 'Home', root_path %> </div> <div id='content'> <% @posts.each do |post| -%> <div class='post'> <h3><%= h post.title %></h3> <strong>by: <%= post.author %></strong> <p><%= post.body %></p> </div> <% end %> </div> </div> </body> </html>
  • 10. ERB / RHTML <?xml version='1.0' encoding='utf-8' ?> !!! XML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" !!! Strict %html{html_attrs} "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang='en-US' xml:lang='en-US' xmlns='http://www.w3.org/1999/xhtml'> %head <head> %title Yet Another Rails Blog <title>Yet Another Rails Blog</title> %body </head> <body> #container <div id='container'> #navigation <div id='navigation'> = link_to('Home', root_path) <%= link_to 'Home', root_path %> </div> <div id='content'> <% @posts.each do |post| -%> <div class='post'> <h3><%= h post.title %></h3> <strong>by: <%= post.author %></strong> <p><%= post.body %></p> </div> <% end %> </div> </div> </body> </html>
  • 11. Hamlified! <?xml version='1.0' encoding='utf-8' ?> !!! XML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" !!! Strict %html{html_attrs} "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang='en-US' xml:lang='en-US' xmlns='http://www.w3.org/1999/xhtml'> %head <head> %title Yet Another Rails Blog <title>Yet Another Rails Blog</title> %body </head> <body> #container <div id='container'> #navigation <div id='navigation'> = link_to('Home', root_path) <%= link_to 'Home', root_path %> </div> #content <div id='content'> <%@posts.each do |post| -%> - @posts.each do |post| .post <div class='post'> <h3><%=h(post.title) %></h3> %h3= h post.title <strong>by:"by: post.author %></strong> %strong= <%= #{h(post.author)}" <p><%=post.body %></p> %p= post.body </div> <% end %> </div> </div> </body> </html>
  • 12. Haml Deconstructed !!! XML !!! Strict %html{html_attrs} %head %title Yet Another Rails Blog %body #container #navigation = link_to('Home', root_path) #content - @posts.each do |post| .post %h3= h(post.title) %strong= "by: #{h(post.author)}" %p= post.body
  • 13. Haml Deconstructed XHTML document type !!! XML !!! Strict %html{html_attrs} %head %title Yet Another Rails Blog %body #container #navigation = link_to('Home', root_path) #content - @posts.each do |post| .post %h3= h(post.title) %strong= "by: #{h(post.author)}" %p= post.body
  • 14. Haml Deconstructed XHTML document type !!! XML XHTML tag with !!! Strict static content %html{html_attrs} %head %title Yet Another Rails Blog %body #container #navigation = link_to('Home', root_path) #content - @posts.each do |post| .post %h3= h(post.title) %strong= "by: #{h(post.author)}" %p= post.body
  • 15. Haml Deconstructed XHTML document type Haml helper method !!! XML XHTML tag with !!! Strict static content %html{html_attrs} %head %title Yet Another Rails Blog %body #container #navigation = link_to('Home', root_path) #content - @posts.each do |post| .post %h3= h(post.title) %strong= "by: #{h(post.author)}" %p= post.body
  • 16. Haml Deconstructed XHTML document type Haml helper method !!! XML XHTML tag with !!! Strict static content %html{html_attrs} %head %title Yet Another Rails Blog DIV tag with ID %body #container #navigation = link_to('Home', root_path) #content - @posts.each do |post| .post %h3= h(post.title) %strong= "by: #{h(post.author)}" %p= post.body
  • 17. Haml Deconstructed XHTML document type Haml helper method !!! XML XHTML tag with !!! Strict static content %html{html_attrs} %head %title Yet Another Rails Blog DIV tag with ID %body #container #navigation = link_to('Home', root_path) Execute Ruby code #content - @posts.each do |post| .post %h3= h(post.title) %strong= "by: #{h(post.author)}" %p= post.body
  • 18. Haml Deconstructed XHTML document type Haml helper method !!! XML XHTML tag with !!! Strict static content %html{html_attrs} %head %title Yet Another Rails Blog DIV tag with ID %body #container #navigation = link_to('Home', root_path) Execute Ruby code #content - @posts.each do |post| .post %h3= h(post.title) XHTML tag with %strong= "by: #{h(post.author)}" %p= post.body dynamic content
  • 19. XHTML Output <?xml version='1.0' encoding='utf-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang='en-US' xml:lang='en-US' xmlns='http://www.w3.org/1999/xhtml'> <head> <title>Yet Another Rails Blog</title> </head> <body> <div id='container'> <div id='navigation'> <a href="/">Home</a> </div> <div id='content'> <div class='post'> <h3>January Refresh Recap</h3> <strong>by: Patrick</strong> <p>It was awesome!</p> </div> ... </div> </div> </body> </html>
  • 20. Off the Rails? $ irb >> require 'rubygems' => true >> require 'haml' => true >> Haml::Engine.new('%p Hello, World').render => "<p>Hello, World</p>n"
  • 21. Why Use It? • Creates well-formatted markup • Automatic closing of tags • Less “noise”
  • 22. Why Not? • Buildout must happen inside Rails • XHTML is a widespread standard • Performance
  • 23. Resources Other templating systems • Erubis • Markaby • pHAML Tutorial & Documentation • http://haml.hamptoncatlin.com/tutorial/ • http://haml.hamptoncatlin.com/docs/ TextMate Bundle (via SVN) • http://macromates.com/svn/Bundles/trunk