SlideShare a Scribd company logo
1 of 27
HAML
Web Templating for Human Beings
Introduction

HAML is Markup language

 Its purpose is to describe
HTML in a clean, simple way
Introduction

    Lets face it, HTML is
    pretty annoying
Introduction


HAML aims to solve problems
with ordinary HTML coding
Introduction
• Markup should be beautiful
• Markup should be DRY
 • Too much repetition in HTML and
    templating engines like ERB
• Markup should be well-indented
• Markup structure should be clear
The problems with HTML
          Programmers don’t speak
          HTML

          The whole concept of
          markup is foreign as
          there’s no logic involved.
The problems with HTML
        The mix of markup and
        logic seems a bit odd, if not
        ugly.

        Markup should be beautiful,
        not just code
The problems with HTML
There’s just too much repetition in HTML.
All those open and close tags are redundant
The problems with HTML

          Keeping track of open
          and close HTML and
          template tags is tedious.
HAML to the rescue
<ul id=”navigation”>
 <li class=”menu_item”>
   <a href=”/home” title=”Home”>Home</a>
 </li>
</ul>

%ul#navigation
 %li.menu_item
   %a({:href => “/home”,
       :title => “Home”
      })
      Home
HAML Basics
!!! 5
%html
  %head
    %title Haml Test
  %body
    #header
      %h1 Welcome to my blog
      %nav#navigation
    #content
      = yield
HAML Basics

• HTML Tags are prefixed with %
• ID attribute is prefixed with #
• Class attribute is prefixed with .
• Default HTML tag is <div>
HAML Basics

• Additional attributes are passed as
 • space-separated attr./value pairs
    •   %a(title=@title href=href) Stuff

  • attr./value hash
    •   %a{:title => @title, :href => href} Stuff
HAML Formatting
Remove whitespace using < and > characters

%img
%img>
%img

Compiles into

<img /><img /><img />
HAML Formatting

%p<= “FoonBar”

Compiles into

<p>Foo
Bar</p>
HAML Formatting

Escape HTML entities using the & sign

&= “I like Cheese & Crackers”

Compiles into

I like Cheese &amp; Crackers
HAML Formatting

Disable HTML unescaping using the ! sign

!= “<strong>Foo</strong>”

Compiles into

<strong>Foo</strong>
Dynamic HAML

HAML supports dynamic content as well as
static content.

(let the real fun begin)
Dynamic HAML

• We use the “=” sign to evaluate dynamic
  code and assign the value to the desired tag
• We use the “-” sign to run code without
  appending a value to any tag
• We use Ruby interpolation to mix static
  and dynamic strings
Dynamic HAML
%h2= “Posts for #{Time.now}”

%ul#posts

- @posts.each do |post|

 %li.post_item
   %h3= post.title
   %p= post.post
   %p=
Dynamic HAML
HAML doesn’t limit us to just plain old code
running and evaluation.

Since markup documents may contain a mix
of other languages (like Javascript or CSS),
we can use Filters to parse those languages
into HAML
HAML Filters
HAML Filters
:javascript
  document.getElementById(‘content’);

:css
  body{
    font:normal normal 14px Arial,sans-serif;
  }

:sass
li
   font:
     family: serif
HAML Filters

:markdown
  Textile
  =======
  Hello, *World*

:textile
  I *really* prefer _#{h flavor}_ jam.
HAML Filters
:zohar

module Haml::Filters::Zohar
  include Haml::Filters::Base

  def render(text)
    # run some snazzy logic
    text
  end
end
HAML interoperability
• Python - HamlPy & DAML (Django)
• PHP - Fammel, pHAML, phpHAML
• .NET - NHaml, MonoRail NHaml
• Javascript - HAML-js
• Perl - Text::Haml
• Java - JHaml
HAML


Questions ?

More Related Content

What's hot

Handout2 formatting tags
Handout2 formatting tagsHandout2 formatting tags
Handout2 formatting tagsNadine Guevarra
 
HTML/CSS/java Script/Jquery
HTML/CSS/java Script/JqueryHTML/CSS/java Script/Jquery
HTML/CSS/java Script/JqueryFAKHRUN NISHA
 
Make Css easy : easy tips for css
Make Css easy : easy tips for cssMake Css easy : easy tips for css
Make Css easy : easy tips for cssshabab shihan
 
HTML 5 Step By Step - Ebook
HTML 5 Step By Step - EbookHTML 5 Step By Step - Ebook
HTML 5 Step By Step - EbookScottperrone
 
Introduction to Cascading Style Sheets
Introduction to Cascading Style SheetsIntroduction to Cascading Style Sheets
Introduction to Cascading Style SheetsTushar Joshi
 
An Seo’s Intro to Web Dev, HTML, CSS and JavaScript
An Seo’s Intro to Web Dev, HTML, CSS and JavaScriptAn Seo’s Intro to Web Dev, HTML, CSS and JavaScript
An Seo’s Intro to Web Dev, HTML, CSS and JavaScriptTroyfawkes
 
Elements of html powerpoint
Elements of html powerpointElements of html powerpoint
Elements of html powerpointAnastasia1993
 
A quick guide to Css and java script
A quick guide to Css and  java scriptA quick guide to Css and  java script
A quick guide to Css and java scriptAVINASH KUMAR
 
Origins and evolution of HTML and XHTML
Origins and evolution of HTML and XHTMLOrigins and evolution of HTML and XHTML
Origins and evolution of HTML and XHTMLHowpk
 
Web I - 02 - XHTML Introduction
Web I - 02 - XHTML IntroductionWeb I - 02 - XHTML Introduction
Web I - 02 - XHTML IntroductionRandy Connolly
 
Cucumber - use it to describe user stories and acceptance criterias
Cucumber - use it to describe user stories and acceptance criteriasCucumber - use it to describe user stories and acceptance criterias
Cucumber - use it to describe user stories and acceptance criteriasGeison Goes
 

What's hot (19)

Html
HtmlHtml
Html
 
LEARN HTML IN A DAY
LEARN HTML IN A DAYLEARN HTML IN A DAY
LEARN HTML IN A DAY
 
Handout2 formatting tags
Handout2 formatting tagsHandout2 formatting tags
Handout2 formatting tags
 
HTML 5 Basics Part One
HTML 5 Basics Part OneHTML 5 Basics Part One
HTML 5 Basics Part One
 
-Haml Presentation
-Haml Presentation-Haml Presentation
-Haml Presentation
 
HTML/CSS/java Script/Jquery
HTML/CSS/java Script/JqueryHTML/CSS/java Script/Jquery
HTML/CSS/java Script/Jquery
 
Make Css easy : easy tips for css
Make Css easy : easy tips for cssMake Css easy : easy tips for css
Make Css easy : easy tips for css
 
HTML 5 Step By Step - Ebook
HTML 5 Step By Step - EbookHTML 5 Step By Step - Ebook
HTML 5 Step By Step - Ebook
 
Html and Xhtml
Html and XhtmlHtml and Xhtml
Html and Xhtml
 
Introduction to Cascading Style Sheets
Introduction to Cascading Style SheetsIntroduction to Cascading Style Sheets
Introduction to Cascading Style Sheets
 
An Seo’s Intro to Web Dev, HTML, CSS and JavaScript
An Seo’s Intro to Web Dev, HTML, CSS and JavaScriptAn Seo’s Intro to Web Dev, HTML, CSS and JavaScript
An Seo’s Intro to Web Dev, HTML, CSS and JavaScript
 
2. html attributes
2. html attributes2. html attributes
2. html attributes
 
Elements of html powerpoint
Elements of html powerpointElements of html powerpoint
Elements of html powerpoint
 
A quick guide to Css and java script
A quick guide to Css and  java scriptA quick guide to Css and  java script
A quick guide to Css and java script
 
Html basic
Html basicHtml basic
Html basic
 
Origins and evolution of HTML and XHTML
Origins and evolution of HTML and XHTMLOrigins and evolution of HTML and XHTML
Origins and evolution of HTML and XHTML
 
Web I - 02 - XHTML Introduction
Web I - 02 - XHTML IntroductionWeb I - 02 - XHTML Introduction
Web I - 02 - XHTML Introduction
 
Cucumber - use it to describe user stories and acceptance criterias
Cucumber - use it to describe user stories and acceptance criteriasCucumber - use it to describe user stories and acceptance criterias
Cucumber - use it to describe user stories and acceptance criterias
 
Html example
Html exampleHtml example
Html example
 

Viewers also liked

Rolling Your Own CSS Methodology
Rolling Your Own CSS MethodologyRolling Your Own CSS Methodology
Rolling Your Own CSS MethodologyFITC
 
Architecting single-page front-end apps
Architecting single-page front-end appsArchitecting single-page front-end apps
Architecting single-page front-end appsZohar Arad
 
Message in a Bottle
Message in a BottleMessage in a Bottle
Message in a BottleZohar Arad
 
CSS Methodology
CSS MethodologyCSS Methodology
CSS MethodologyZohar Arad
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design PatternsZohar Arad
 
Performance front end language
Performance front end languagePerformance front end language
Performance front end languageWei-Yi Chiu
 
DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...
DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...
DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...Jer Clarke
 

Viewers also liked (8)

Haml
HamlHaml
Haml
 
Rolling Your Own CSS Methodology
Rolling Your Own CSS MethodologyRolling Your Own CSS Methodology
Rolling Your Own CSS Methodology
 
Architecting single-page front-end apps
Architecting single-page front-end appsArchitecting single-page front-end apps
Architecting single-page front-end apps
 
Message in a Bottle
Message in a BottleMessage in a Bottle
Message in a Bottle
 
CSS Methodology
CSS MethodologyCSS Methodology
CSS Methodology
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
 
Performance front end language
Performance front end languagePerformance front end language
Performance front end language
 
DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...
DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...
DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...
 

Similar to Introduction to HAML (20)

Learning html. (Part- 1)
Learning html. (Part- 1)Learning html. (Part- 1)
Learning html. (Part- 1)
 
HTML Bootcamp
HTML BootcampHTML Bootcamp
HTML Bootcamp
 
215077679 introduction to HTML
215077679  introduction to HTML215077679  introduction to HTML
215077679 introduction to HTML
 
week 3 slides.pptx
week 3 slides.pptxweek 3 slides.pptx
week 3 slides.pptx
 
Html
HtmlHtml
Html
 
Untitled presentation (8) (1)
Untitled presentation (8) (1)Untitled presentation (8) (1)
Untitled presentation (8) (1)
 
Html Workshop
Html WorkshopHtml Workshop
Html Workshop
 
Html starting
Html startingHtml starting
Html starting
 
Web Development 1 (HTML & CSS)
Web Development 1 (HTML & CSS)Web Development 1 (HTML & CSS)
Web Development 1 (HTML & CSS)
 
Basic Html Notes
Basic Html NotesBasic Html Notes
Basic Html Notes
 
Web forms and html (lect 1)
Web forms and html (lect 1)Web forms and html (lect 1)
Web forms and html (lect 1)
 
Html presentation
Html presentationHtml presentation
Html presentation
 
web development.pdf
web development.pdfweb development.pdf
web development.pdf
 
Computer fundamentals-internet p2
Computer fundamentals-internet p2Computer fundamentals-internet p2
Computer fundamentals-internet p2
 
Basic HTML
Basic HTMLBasic HTML
Basic HTML
 
Html
HtmlHtml
Html
 
Html xhtml tag-sheet
Html xhtml tag-sheetHtml xhtml tag-sheet
Html xhtml tag-sheet
 
Html (hypertext markup language)
Html (hypertext markup language)Html (hypertext markup language)
Html (hypertext markup language)
 
Html introduction
Html introductionHtml introduction
Html introduction
 
Html basics
Html basicsHtml basics
Html basics
 

Recently uploaded

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
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
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 

Recently uploaded (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
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
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

Introduction to HAML

  • 1. HAML Web Templating for Human Beings
  • 2. Introduction HAML is Markup language Its purpose is to describe HTML in a clean, simple way
  • 3. Introduction Lets face it, HTML is pretty annoying
  • 4. Introduction HAML aims to solve problems with ordinary HTML coding
  • 5. Introduction • Markup should be beautiful • Markup should be DRY • Too much repetition in HTML and templating engines like ERB • Markup should be well-indented • Markup structure should be clear
  • 6. The problems with HTML Programmers don’t speak HTML The whole concept of markup is foreign as there’s no logic involved.
  • 7. The problems with HTML The mix of markup and logic seems a bit odd, if not ugly. Markup should be beautiful, not just code
  • 8. The problems with HTML There’s just too much repetition in HTML. All those open and close tags are redundant
  • 9. The problems with HTML Keeping track of open and close HTML and template tags is tedious.
  • 10. HAML to the rescue <ul id=”navigation”> <li class=”menu_item”> <a href=”/home” title=”Home”>Home</a> </li> </ul> %ul#navigation %li.menu_item %a({:href => “/home”, :title => “Home” }) Home
  • 11. HAML Basics !!! 5 %html %head %title Haml Test %body #header %h1 Welcome to my blog %nav#navigation #content = yield
  • 12. HAML Basics • HTML Tags are prefixed with % • ID attribute is prefixed with # • Class attribute is prefixed with . • Default HTML tag is <div>
  • 13. HAML Basics • Additional attributes are passed as • space-separated attr./value pairs • %a(title=@title href=href) Stuff • attr./value hash • %a{:title => @title, :href => href} Stuff
  • 14. HAML Formatting Remove whitespace using < and > characters %img %img> %img Compiles into <img /><img /><img />
  • 16. HAML Formatting Escape HTML entities using the & sign &= “I like Cheese & Crackers” Compiles into I like Cheese &amp; Crackers
  • 17. HAML Formatting Disable HTML unescaping using the ! sign != “<strong>Foo</strong>” Compiles into <strong>Foo</strong>
  • 18. Dynamic HAML HAML supports dynamic content as well as static content. (let the real fun begin)
  • 19. Dynamic HAML • We use the “=” sign to evaluate dynamic code and assign the value to the desired tag • We use the “-” sign to run code without appending a value to any tag • We use Ruby interpolation to mix static and dynamic strings
  • 20. Dynamic HAML %h2= “Posts for #{Time.now}” %ul#posts - @posts.each do |post| %li.post_item %h3= post.title %p= post.post %p=
  • 21. Dynamic HAML HAML doesn’t limit us to just plain old code running and evaluation. Since markup documents may contain a mix of other languages (like Javascript or CSS), we can use Filters to parse those languages into HAML
  • 23. HAML Filters :javascript document.getElementById(‘content’); :css body{ font:normal normal 14px Arial,sans-serif; } :sass li font: family: serif
  • 24. HAML Filters :markdown Textile ======= Hello, *World* :textile I *really* prefer _#{h flavor}_ jam.
  • 25. HAML Filters :zohar module Haml::Filters::Zohar include Haml::Filters::Base def render(text) # run some snazzy logic text end end
  • 26. HAML interoperability • Python - HamlPy & DAML (Django) • PHP - Fammel, pHAML, phpHAML • .NET - NHaml, MonoRail NHaml • Javascript - HAML-js • Perl - Text::Haml • Java - JHaml

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n