SlideShare une entreprise Scribd logo
1  sur  13
Télécharger pour lire hors ligne
Why HAML?




Kirill Zonov (graffzon)
From ERB to Haml (Step 1)
<div class="offering">
  <div class="name">
     <%= offering.name %>
  </div>
  <div class="symbol">
     <%= offering.symbol %>
  </div>
  <div class="last_price">
     <%= number_to_currency offering.last_price %>
  </div>
  <div class="last_traded_at">
     <%= last_trade_at.to_formatted_s(:short) %>
  </div>
  <div class="actions">
     <%= link_to "buy", offering_new_bid_path(offering) %>
     <% if offering.owners.find_by_user_id(session[:uid]) %>
       <%= link_to "sell", offering_new_ask_path(offering) %>
     <% end %>
  </div>
</div>
From ERB to Haml (Step 2)

<div class="offering">
  <div class="name">
     <%= offering.name %>
  <div class="symbol">
     <%= offering.symbol %>
  <div class="last_price">
     <%= number_to_currency offering.last_price %>
  <div class="last_traded_at">
     <%= last_trade_at.to_formatted_s(:short) %>
  <div class="actions">
     <%= link_to "buy", offering_new_bid_path(offering) %>
     <% if offering.owners.find_by_user_id(session[:uid]) %>
       <%= link_to "sell", offering_new_ask_path(offering) %>
From ERB to Haml (Step 3)

.offering
   .name
       = offering.name
    .symbol
       = offering.symbol
    .last_price
       = number_to_currency offering.last_price
    .last_traded_at
       = last_trade_at.to_formatted_s(:short)
    .actions
       = link_to "buy", offering_new_bid_path(offering)
       - if offering.owners.find_by_user_id(session[:uid])
          = link_to "sell", offering_new_ask_path(offering)
Main ideas of Haml

               Markup should:



● be beautiful
● be clean
● be sensible
● follow the rules
Rules of indentations

.some_div
  line one
  line two                <div class='some_div'> line one line two </div> <div
                          class='some_div_two'> line one </div>
.some_div_two             line two
  line one
line two



If we try that:
%h1 test
work?
(<h1> test
         work? </h1> )

Immediately we take error:
Illegal nesting: content can't be both given on the same line as %h1 and nested within it.
Size of code (erb)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-
transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <title>
      <%= configatron.app_name %> - <%= yield(:title) || 'Home' %>
   </title>
   <%= stylesheet_link_tag :flutie, 'application' %>
   <%= javascript_include_tag :defaults, 'rails.validations', 'jquery-snippet' %>
   <%= csrf_meta_tag %>
   <%= yield(:head) %>
   <%= yield :javascript %>
 </head>
<body>
   <div class="content">
   <%= render 'layouts/navigation' %>
   <hr />
   <%= render 'layouts/messages' %>
   <% if show_title? %>
      <h1>
         <%= yield(:title) %>
      </h1>
   <% end %>
   <%= yield %>
   </div>
</body>
</html>
Size of code (haml)


!!!
%html
  %head
  %meta{'http-equiv' => "Content-Type", 'content' => "text/html; charset=utf-8"}
  %title #{configatron.app_name} - #{yield(:title) || 'Home'}
  = stylesheet_link_tag :flutie, 'application'
  = javascript_include_tag :defaults, 'rails.validations', 'jquery-snippet'
  = csrf_meta_tag
  = yield(:head)
  = yield :javascript
%body .content
  = render 'layouts/navigation'
  %hr = render 'layouts/messages'
  %h1=yield(:title)
  if show_title?
    = yield
No need for words ;)
Any problems with haml?




● Perfomance problems
● Need for retraining
Perfomance

   Haml - 0.00033s
   ERB - 0.000222s
   Slim - 0.000254s
   Код:


Haml                                   ERB                                           Slim
%h1 Haml#index %p Find me in           <h1>Erb#index</h1> <p>Find me in              h1 Haml#index p Find me in
app/views/haml/index.html.erb =@haml   app/views/erb/index.html.erb</p> <%= @erb %   app/views/slim/index.html.erb = @slim
                                       >
Intuitive perception

Html with css:
<div class="highlight">
  this is some stuff
</div>
.highlight {
 border: 1px solid #f00 }

Haml with sass:
.highlight
  this is some stuff

.highlight
 border: 1px solid #f00
Now you can see that Haml is
          REALLY better than erb



You also can take a look for my blog graffzon.com

Contenu connexe

Tendances

Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)
Thinkful
 
Upstate CSCI 450 WebDev Chapter 2
Upstate CSCI 450 WebDev Chapter 2Upstate CSCI 450 WebDev Chapter 2
Upstate CSCI 450 WebDev Chapter 2
DanWooster1
 
Coder Presentation
Coder  PresentationCoder  Presentation
Coder Presentation
Doug Green
 

Tendances (19)

9. lower in Symfony 4
9. lower in Symfony 49. lower in Symfony 4
9. lower in Symfony 4
 
HTML 5 Basics Part One
HTML 5 Basics Part OneHTML 5 Basics Part One
HTML 5 Basics Part One
 
Java script
Java scriptJava script
Java script
 
Styling with CSS
Styling with CSSStyling with CSS
Styling with CSS
 
jQuery from the very beginning
jQuery from the very beginningjQuery from the very beginning
jQuery from the very beginning
 
What's new in Rails 2?
What's new in Rails 2?What's new in Rails 2?
What's new in Rails 2?
 
7. copy2 in Symfony 4
7. copy2 in Symfony 47. copy2 in Symfony 4
7. copy2 in Symfony 4
 
JavaScript - Part-1
JavaScript - Part-1JavaScript - Part-1
JavaScript - Part-1
 
Merb jQuery
Merb jQueryMerb jQuery
Merb jQuery
 
Simple Markdown with Ecto and Protocols
Simple Markdown with Ecto and ProtocolsSimple Markdown with Ecto and Protocols
Simple Markdown with Ecto and Protocols
 
Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)
 
Angular directive filter and routing
Angular directive filter and routingAngular directive filter and routing
Angular directive filter and routing
 
Mechanize at the Ruby Drink-up of Sophia, November 2011
Mechanize at the Ruby Drink-up of Sophia, November 2011Mechanize at the Ruby Drink-up of Sophia, November 2011
Mechanize at the Ruby Drink-up of Sophia, November 2011
 
Upstate CSCI 450 WebDev Chapter 2
Upstate CSCI 450 WebDev Chapter 2Upstate CSCI 450 WebDev Chapter 2
Upstate CSCI 450 WebDev Chapter 2
 
Story Driven Development With Cucumber
Story Driven Development With CucumberStory Driven Development With Cucumber
Story Driven Development With Cucumber
 
JavaScript: Ajax & DOM Manipulation
JavaScript: Ajax & DOM ManipulationJavaScript: Ajax & DOM Manipulation
JavaScript: Ajax & DOM Manipulation
 
Coder Presentation
Coder  PresentationCoder  Presentation
Coder Presentation
 
JavaScript Introduction
JavaScript IntroductionJavaScript Introduction
JavaScript Introduction
 
URUG Ruby on Rails Workshop - Sesssion 5
URUG Ruby on Rails Workshop - Sesssion 5URUG Ruby on Rails Workshop - Sesssion 5
URUG Ruby on Rails Workshop - Sesssion 5
 

En vedette

Facebook for public health - NPIN
Facebook for public health - NPINFacebook for public health - NPIN
Facebook for public health - NPIN
Giuseppe Fattori
 
Columbia Corporate Strategy Retreat 03.14.12
Columbia Corporate Strategy Retreat 03.14.12Columbia Corporate Strategy Retreat 03.14.12
Columbia Corporate Strategy Retreat 03.14.12
Mightybytes
 
As media course work- evaluation
As media course work- evaluationAs media course work- evaluation
As media course work- evaluation
Billysmedia
 
Arthur conan doyle2
Arthur conan doyle2Arthur conan doyle2
Arthur conan doyle2
ian11644
 
As media course work- evaluation
As media course work- evaluationAs media course work- evaluation
As media course work- evaluation
Billysmedia
 
20121204 are your lights on?
20121204 are your lights on?20121204 are your lights on?
20121204 are your lights on?
jasonmel
 
Arthur conan doyle2
Arthur conan doyle2Arthur conan doyle2
Arthur conan doyle2
ian11644
 
Ec tech heritage buildings 11_mn01
Ec tech heritage buildings 11_mn01Ec tech heritage buildings 11_mn01
Ec tech heritage buildings 11_mn01
Frost & Sullivan
 

En vedette (20)

Facebook for public health - NPIN
Facebook for public health - NPINFacebook for public health - NPIN
Facebook for public health - NPIN
 
2.tao of topic maps
2.tao of topic maps2.tao of topic maps
2.tao of topic maps
 
3.typing and advanced constructs
3.typing and advanced constructs3.typing and advanced constructs
3.typing and advanced constructs
 
Eurovegas
EurovegasEurovegas
Eurovegas
 
MAN2012
MAN2012MAN2012
MAN2012
 
Columbia Corporate Strategy Retreat 03.14.12
Columbia Corporate Strategy Retreat 03.14.12Columbia Corporate Strategy Retreat 03.14.12
Columbia Corporate Strategy Retreat 03.14.12
 
As media course work- evaluation
As media course work- evaluationAs media course work- evaluation
As media course work- evaluation
 
Saa s案例分析01
Saa s案例分析01Saa s案例分析01
Saa s案例分析01
 
Arthur conan doyle2
Arthur conan doyle2Arthur conan doyle2
Arthur conan doyle2
 
Pertemuan 7
Pertemuan 7Pertemuan 7
Pertemuan 7
 
Distribution of Silicon iin the Allumiinum Matriix for Rear Passiivated Solla...
Distribution of Silicon iin the Allumiinum Matriix for Rear Passiivated Solla...Distribution of Silicon iin the Allumiinum Matriix for Rear Passiivated Solla...
Distribution of Silicon iin the Allumiinum Matriix for Rear Passiivated Solla...
 
As media course work- evaluation
As media course work- evaluationAs media course work- evaluation
As media course work- evaluation
 
6. analisis jaringan
6. analisis jaringan6. analisis jaringan
6. analisis jaringan
 
20121204 are your lights on?
20121204 are your lights on?20121204 are your lights on?
20121204 are your lights on?
 
Arthur conan doyle2
Arthur conan doyle2Arthur conan doyle2
Arthur conan doyle2
 
Ec tech heritage buildings 11_mn01
Ec tech heritage buildings 11_mn01Ec tech heritage buildings 11_mn01
Ec tech heritage buildings 11_mn01
 
Ragged school
Ragged schoolRagged school
Ragged school
 
Backup and Security Lite WCPHX13
Backup and Security Lite WCPHX13Backup and Security Lite WCPHX13
Backup and Security Lite WCPHX13
 
Body parts
Body partsBody parts
Body parts
 
Pertemuan 8
Pertemuan 8Pertemuan 8
Pertemuan 8
 

Similaire à Haml. New HTML? (RU)

Action View Form Helpers - 1, Season 2
Action View Form Helpers - 1, Season 2Action View Form Helpers - 1, Season 2
Action View Form Helpers - 1, Season 2
RORLAB
 
OSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialOSDC 2009 Rails Turtorial
OSDC 2009 Rails Turtorial
Yi-Ting Cheng
 
Documenting from the Trenches
Documenting from the TrenchesDocumenting from the Trenches
Documenting from the Trenches
Xavier Noria
 

Similaire à Haml. New HTML? (RU) (20)

AEM Sightly Template Language
AEM Sightly Template LanguageAEM Sightly Template Language
AEM Sightly Template Language
 
The Rails Way
The Rails WayThe Rails Way
The Rails Way
 
Geek Moot '09 -- Smarty 101
Geek Moot '09 -- Smarty 101Geek Moot '09 -- Smarty 101
Geek Moot '09 -- Smarty 101
 
Action View Form Helpers - 1, Season 2
Action View Form Helpers - 1, Season 2Action View Form Helpers - 1, Season 2
Action View Form Helpers - 1, Season 2
 
Clean separation
Clean separationClean separation
Clean separation
 
Html, CSS, Javascript, Jquery, Meteor應用
Html, CSS, Javascript, Jquery, Meteor應用Html, CSS, Javascript, Jquery, Meteor應用
Html, CSS, Javascript, Jquery, Meteor應用
 
OSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialOSDC 2009 Rails Turtorial
OSDC 2009 Rails Turtorial
 
RoR 101: Session 2
RoR 101: Session 2RoR 101: Session 2
RoR 101: Session 2
 
Documenting from the Trenches
Documenting from the TrenchesDocumenting from the Trenches
Documenting from the Trenches
 
SEO for Developers
SEO for DevelopersSEO for Developers
SEO for Developers
 
Introduction of Html/css/js
Introduction of Html/css/jsIntroduction of Html/css/js
Introduction of Html/css/js
 
Rails antipattern-public
Rails antipattern-publicRails antipattern-public
Rails antipattern-public
 
Rails antipatterns
Rails antipatternsRails antipatterns
Rails antipatterns
 
Rails for Beginners - Le Wagon
Rails for Beginners - Le WagonRails for Beginners - Le Wagon
Rails for Beginners - Le Wagon
 
Building Potent WordPress Websites
Building Potent WordPress WebsitesBuilding Potent WordPress Websites
Building Potent WordPress Websites
 
Ruby on Rails at PROMPT ISEL '11
Ruby on Rails at PROMPT ISEL '11Ruby on Rails at PROMPT ISEL '11
Ruby on Rails at PROMPT ISEL '11
 
Php
PhpPhp
Php
 
Angular.js Fundamentals
Angular.js FundamentalsAngular.js Fundamentals
Angular.js Fundamentals
 
AngularJS vs. Ember.js vs. Backbone.js
AngularJS vs. Ember.js vs. Backbone.jsAngularJS vs. Ember.js vs. Backbone.js
AngularJS vs. Ember.js vs. Backbone.js
 
Intro to Haml
Intro to HamlIntro to Haml
Intro to Haml
 

Plus de Kirill Zonov

Plus de Kirill Zonov (7)

AWS X-Ray introduction and my experience
AWS X-Ray introduction and my experienceAWS X-Ray introduction and my experience
AWS X-Ray introduction and my experience
 
Kubernetes and Helm 101
Kubernetes and Helm 101Kubernetes and Helm 101
Kubernetes and Helm 101
 
IBM Watson as tutor, not a voice interface
IBM Watson as tutor, not a voice interfaceIBM Watson as tutor, not a voice interface
IBM Watson as tutor, not a voice interface
 
DevOpsDays Berlin 2018 Terraform hands-on workshop
DevOpsDays Berlin 2018 Terraform hands-on workshopDevOpsDays Berlin 2018 Terraform hands-on workshop
DevOpsDays Berlin 2018 Terraform hands-on workshop
 
Go for Rubyists. August 2018. RUG-B Meetup
Go for Rubyists. August 2018. RUG-B MeetupGo for Rubyists. August 2018. RUG-B Meetup
Go for Rubyists. August 2018. RUG-B Meetup
 
Ruby on Grapes. Why did we choose Grape and why I would choose it again
Ruby on Grapes. Why did we choose Grape and why I would choose it againRuby on Grapes. Why did we choose Grape and why I would choose it again
Ruby on Grapes. Why did we choose Grape and why I would choose it again
 
Haskell. Getting started (RU)
Haskell. Getting started (RU)Haskell. Getting started (RU)
Haskell. Getting started (RU)
 

Dernier

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Dernier (20)

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 

Haml. New HTML? (RU)

  • 2. From ERB to Haml (Step 1) <div class="offering"> <div class="name"> <%= offering.name %> </div> <div class="symbol"> <%= offering.symbol %> </div> <div class="last_price"> <%= number_to_currency offering.last_price %> </div> <div class="last_traded_at"> <%= last_trade_at.to_formatted_s(:short) %> </div> <div class="actions"> <%= link_to "buy", offering_new_bid_path(offering) %> <% if offering.owners.find_by_user_id(session[:uid]) %> <%= link_to "sell", offering_new_ask_path(offering) %> <% end %> </div> </div>
  • 3. From ERB to Haml (Step 2) <div class="offering"> <div class="name"> <%= offering.name %> <div class="symbol"> <%= offering.symbol %> <div class="last_price"> <%= number_to_currency offering.last_price %> <div class="last_traded_at"> <%= last_trade_at.to_formatted_s(:short) %> <div class="actions"> <%= link_to "buy", offering_new_bid_path(offering) %> <% if offering.owners.find_by_user_id(session[:uid]) %> <%= link_to "sell", offering_new_ask_path(offering) %>
  • 4. From ERB to Haml (Step 3) .offering .name = offering.name .symbol = offering.symbol .last_price = number_to_currency offering.last_price .last_traded_at = last_trade_at.to_formatted_s(:short) .actions = link_to "buy", offering_new_bid_path(offering) - if offering.owners.find_by_user_id(session[:uid]) = link_to "sell", offering_new_ask_path(offering)
  • 5. Main ideas of Haml Markup should: ● be beautiful ● be clean ● be sensible ● follow the rules
  • 6. Rules of indentations .some_div line one line two <div class='some_div'> line one line two </div> <div class='some_div_two'> line one </div> .some_div_two line two line one line two If we try that: %h1 test work? (<h1> test work? </h1> ) Immediately we take error: Illegal nesting: content can't be both given on the same line as %h1 and nested within it.
  • 7. Size of code (erb) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1- transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title> <%= configatron.app_name %> - <%= yield(:title) || 'Home' %> </title> <%= stylesheet_link_tag :flutie, 'application' %> <%= javascript_include_tag :defaults, 'rails.validations', 'jquery-snippet' %> <%= csrf_meta_tag %> <%= yield(:head) %> <%= yield :javascript %> </head> <body> <div class="content"> <%= render 'layouts/navigation' %> <hr /> <%= render 'layouts/messages' %> <% if show_title? %> <h1> <%= yield(:title) %> </h1> <% end %> <%= yield %> </div> </body> </html>
  • 8. Size of code (haml) !!! %html %head %meta{'http-equiv' => "Content-Type", 'content' => "text/html; charset=utf-8"} %title #{configatron.app_name} - #{yield(:title) || 'Home'} = stylesheet_link_tag :flutie, 'application' = javascript_include_tag :defaults, 'rails.validations', 'jquery-snippet' = csrf_meta_tag = yield(:head) = yield :javascript %body .content = render 'layouts/navigation' %hr = render 'layouts/messages' %h1=yield(:title) if show_title? = yield
  • 9. No need for words ;)
  • 10. Any problems with haml? ● Perfomance problems ● Need for retraining
  • 11. Perfomance Haml - 0.00033s ERB - 0.000222s Slim - 0.000254s Код: Haml ERB Slim %h1 Haml#index %p Find me in <h1>Erb#index</h1> <p>Find me in h1 Haml#index p Find me in app/views/haml/index.html.erb =@haml app/views/erb/index.html.erb</p> <%= @erb % app/views/slim/index.html.erb = @slim >
  • 12. Intuitive perception Html with css: <div class="highlight"> this is some stuff </div> .highlight { border: 1px solid #f00 } Haml with sass: .highlight this is some stuff .highlight border: 1px solid #f00
  • 13. Now you can see that Haml is REALLY better than erb You also can take a look for my blog graffzon.com