Danial Parsa Negin Parya. HTML Abstraction Markup Language Doesn’t use of traditional inline...
-
Upload
magnus-walker -
Category
Documents
-
view
214 -
download
0
Transcript of Danial Parsa Negin Parya. HTML Abstraction Markup Language Doesn’t use of traditional inline...
![Page 1: Danial Parsa Negin Parya. HTML Abstraction Markup Language Doesn’t use of traditional inline coding. Makes markup as elegant as it can be. Haml's.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e735503460f94b72710/html5/thumbnails/1.jpg)
HAMLDanial ParsaNegin Parya
![Page 2: Danial Parsa Negin Parya. HTML Abstraction Markup Language Doesn’t use of traditional inline coding. Makes markup as elegant as it can be. Haml's.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e735503460f94b72710/html5/thumbnails/2.jpg)
WHAT IS HAML?
HTML Abstraction Markup Language
Doesn’t use of traditional inline coding.
Makes markup as elegant as it can be.
Haml's equivalent for CSS is Sass.
![Page 3: Danial Parsa Negin Parya. HTML Abstraction Markup Language Doesn’t use of traditional inline coding. Makes markup as elegant as it can be. Haml's.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e735503460f94b72710/html5/thumbnails/3.jpg)
HAML PRINCIPALS
Markup should be beautiful
Markup should be DRY
<h1>Teen Wolf</h1>
Markup should be well-indented
XHTML structure should be clear
![Page 4: Danial Parsa Negin Parya. HTML Abstraction Markup Language Doesn’t use of traditional inline coding. Makes markup as elegant as it can be. Haml's.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e735503460f94b72710/html5/thumbnails/4.jpg)
WHY USE HAML?
<% if @users.empty? %> <div class="empty_collection"> <em>Could not find any users.</em> </div><% else %> <table class="users_list"> <thead> <tr> <th>Name</th> <th>Email</th> <th>Age</th> </tr> </thead> <tbody> <% @users.each do |user| %> <tr class="<%= cycle('odd','even') %>"> <td><%= user.name %></td> <td><%= user.email %></td> <td><%= user.age %></td> </tr> <% end %> </tbody> </table><% end %>
if @users.empty? .empty_collection %em Could not find any users- else %table.users_list %thead %tr %th Name %th Email %th Age %tbody - @users.each do |user| %tr{:class => cycle('odd','even')} %td= user.name %td= user.email %td= user.age
![Page 5: Danial Parsa Negin Parya. HTML Abstraction Markup Language Doesn’t use of traditional inline coding. Makes markup as elegant as it can be. Haml's.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e735503460f94b72710/html5/thumbnails/5.jpg)
INSTALL HAML
Standard Gem gem install haml
haml-edge Gem gem install haml-edge
Installation from Git git clone git://github.com/nex3/haml.git cd haml rake install
![Page 6: Danial Parsa Negin Parya. HTML Abstraction Markup Language Doesn’t use of traditional inline coding. Makes markup as elegant as it can be. Haml's.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e735503460f94b72710/html5/thumbnails/6.jpg)
ENABLE HAML IN RAILS
before Rails 3, add the following line to environment.rb:
config.gem "haml“
For Rails 3 add the following line to the Gemfile:
gem "haml"
![Page 7: Danial Parsa Negin Parya. HTML Abstraction Markup Language Doesn’t use of traditional inline coding. Makes markup as elegant as it can be. Haml's.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e735503460f94b72710/html5/thumbnails/7.jpg)
GETTING STARTED
app/views/account/login.html.erb → app/views/account/login.html.haml
![Page 8: Danial Parsa Negin Parya. HTML Abstraction Markup Language Doesn’t use of traditional inline coding. Makes markup as elegant as it can be. Haml's.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e735503460f94b72710/html5/thumbnails/8.jpg)
HOW TO CONVERT?
![Page 9: Danial Parsa Negin Parya. HTML Abstraction Markup Language Doesn’t use of traditional inline coding. Makes markup as elegant as it can be. Haml's.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e735503460f94b72710/html5/thumbnails/9.jpg)
ATTRIBUTE METHODS
def html_attrs(lang = 'en-US') {:xmlns => "http://www.w3.org/1999/xhtml",
'xml:lang' => lang, :lang => lang} endThen it can be used like:%html{html_attrs('fr-fr')}
<html lang='fr-fr' xml:lang='fr-fr' xmlns='http://www.w3.org/1999/xhtml'>
</html>
![Page 10: Danial Parsa Negin Parya. HTML Abstraction Markup Language Doesn’t use of traditional inline coding. Makes markup as elegant as it can be. Haml's.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e735503460f94b72710/html5/thumbnails/10.jpg)
ELEMENT NAME: %
%one %two %three Hey there
<one> <two> <three>Hey there</three> </two> </one>
![Page 11: Danial Parsa Negin Parya. HTML Abstraction Markup Language Doesn’t use of traditional inline coding. Makes markup as elegant as it can be. Haml's.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e735503460f94b72710/html5/thumbnails/11.jpg)
CLASS AND ID: . AND #
is compiled to:
![Page 12: Danial Parsa Negin Parya. HTML Abstraction Markup Language Doesn’t use of traditional inline coding. Makes markup as elegant as it can be. Haml's.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e735503460f94b72710/html5/thumbnails/12.jpg)
RUNNING RUBY: -
-foo = "hello“-foo << " there" -foo << " you!" %p= foo
is compiled to:<p> hello there you! </p>
![Page 13: Danial Parsa Negin Parya. HTML Abstraction Markup Language Doesn’t use of traditional inline coding. Makes markup as elegant as it can be. Haml's.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e735503460f94b72710/html5/thumbnails/13.jpg)
REFERENCES
http://haml-lang.com/docs/yardoc/file.HAML_REFERENCE.html
http://haml-lang.com/ http://en.wikipedia.org/wiki/Haml http://blog.digimonkey.com/2010/02/wh
y-use-haml-and-sass-i-already-know-html/