ERB vs HAML conversion of an if condition? ERB vs HAML conversion of an if condition? ruby-on-rails ruby-on-rails

ERB vs HAML conversion of an if condition?


HAML is indentation based, and the parser can be tricky. Replace

- if current_user= link_to 'Edit Profile', edit_user_path(current_user.id)= link_to 'Logout', logout_path- else= link_to 'Register', new_user_path= link_to 'Login', login_path

with

- if current_user  = link_to 'Edit Profile', edit_user_path(current_user.id)  = link_to 'Logout', logout_path- else  = link_to 'Register', new_user_path  = link_to 'Login', login_path

and give it a try. Notice how the indentation changed on the link_to lines.


- if current_user  = link_to 'Edit Profile', edit_user_path(current_user.id)  = link_to 'Logout', logout_path- else  = link_to 'Register', new_user_path  = link_to 'Login', login_path