2. Overview
> What is Haml
> Why Haml is used
> Examples of HTML vs. HAML code *scaffolded a table that takes in name and age
> Haml and javascript
> Errors
> Summary
3. WhatisHaml(HTML abstraction markup language)
Indented, very clean and easy to read Markup
> Takes HTML tags < > and replaces them with %
> Takes Class and ID and defines them as . and #
inside documents
> Templating engine for Ruby on Rails
Haml loves to be clean and simple
4. Hamlcontinued...
> Haml uses indentation instead of end tags
> Replaces ERB files of HTML to embed ruby without all
the markup
>Implements Rails templates with the .haml extension
> Focuses on cleanliness, readability, and production
speed
5. Comparison HTML vs HAML
HTML
● <li> </li>
● <div class=“green_font”></div>
<div id=“notice”></div>
● .html.erb
● <% field %>
HAML
● %li
● .green_font
#notice
● .html.haml
● = field
8. _form.HTML.erb
Form
> Has an error message
> Takes a name and age of hippo
> Embedded Ruby code <% %>
> Classes are defined within a div
and labeled with class =
> Creates a hippo on submit
Characters = 568
10. _form.HTML.haml
Form
> Same error message
> Still takes a name and age of hippo
> Embedded Ruby code With =
*Without <% %>
> Classes are defined with .
> Will create a Hippo
Characters = 377
17. JavascriptandHaml
> You can pass ruby variables easily to javascript
> Can place javascript directly into a haml file if it is small and simple
Example of an alert with javascript in a haml file
18. Warning!Thingsdogowrong...
> Haml will break if it is
not properly indented
or spaced correctly
> Nesting text can
break easily.
Sometimes, Haml gets angry...
19. Summary
> Programmers enjoy Haml because of how clean the code is
> There are no end tags required and les characters overall
> Cool markup to learn if you are using ruby on rails
> Errors in rails will tell you what’s exactly wrong so it is okay to try and learn
> Seen in a lot of current rails projects
> There is a lot more to learn . . .