Direkt zum Hauptbereich

HAML

Yesterday I did some coding regarding the output of my diagnose! app.
Doing that I discovered the ease of HAML over ERB/HTML.

This is HTML and even it looks awful it would be parsed right:

 <div class='example'>  
         <table cellspacing='0'>  
   <thead>  
    <tr class='odd'>  
                     <th>Title</th>  
    </tr>  
           </thead>  
   <tbody>  
    <tr class='even'>  
            <th>Single</th>
    </tr>  
  </tbody>
                  </table>  
 </div>  

On the other hand HAML reads whitespaces (like YAML):

 .example  
  %table{:cellspacing => "0"}  
   %thead  
    %tr.odd  
     %th Title
   %tbody  
    %tr.even  
     %th Single

Furthermore its obvious that HAML is more readable because of no trailing tags.
And this is the only pro for me that counts: readability.

Have a look yourself: Tutorial on HAML

Kommentare