Monday 3 December 2012

ERB Makes My Eyes Bleed

I'm sure it makes your eyes bleed too, even if you haven't realized this yet. Start using Haml, now! Here's a snippet from my navigation partial from a Rails app to convince you to make the shift.


- if !user_signed_in? && !client_user_signed_in?
    %li#client-login
      = link_to 'Shopper Login', new_client_user_session_path
    %li#client-signup
      = link_to 'Shopper Sign Up', new_client_user_registration_path
    %li#admin-login
      = link_to 'I am Admin', new_user_session_path

Now let me write the same (not good) code in erb:


<% if !user_signed_in? && !client_user_signed_in? %>
    <li id="client-login"> 
      <%= link_to 'Shopper Login', new_client_user_session_path %>
    </li>
    <li id="client-signup">
      <%= link_to 'Shopper Sign Up', new_client_user_registration_path %>
    </li>
    <li id="admin-login">
      <%= link_to 'I am Admin', new_user_session_path %>
    </li>

Let the code speak for itself!

No comments:

Post a Comment