Introduction to HAML
Click here to load reader
-
Upload
paramisoft -
Category
Software
-
view
94 -
download
0
description
Transcript of Introduction to HAML
INTRODUCTION TO
HAML
HAML
HAML : HTML Abstract Markup Language Light weight Avoid inline code
Main ideas of Haml
Markup should
Be beautiul Be clean Be sensible
FEATURES
Whitespace active Well-formatted markup DRY Follows css conventions Implements rails templates with the .haml extention
Size of code(erb) <table class="users_list"> <thead> <tr> <th>Name</th> <th>Email</th> </tr> </thead> <tbody> <% @users.each do |user| %> <tr> <td><%= user.name %></td> <td><%= user.email %></td> </tr> <% end %> </tbody> </table><% end %>
Size of code(HAML)
%table.users_list %thead %tr %th Name %th Email %tbody - @users.each do |user| %tr %td= user.name %td= user.email
No need for words :)
ERB : 16 lines of code HAML: 10 lines of code 37% less key presses in case of haml
Installing Haml
Gem 'haml' Geneate rails application setup for haml -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb
Convert to HAML ERB <strong><%= item.title %></strong> Haml %strong= item.title HTML <strong class="code" id="message">Hello, World!</strong> Haml %strong{:class => "code", :id => "message"} Hello, World! %strong.code#message Hello, World!
Why not haml
Whitespace can have syntatic meaning Many editors not supporting haml Needs to be install Can be slower than html Without ugly 2.803 + 0.036 With ugly 1.037 + 1.0124
Thank you