Je commence avec HAML et je travaille sur la conversion de mon premier fichier. L'omission ostensiblement correcte du "- fin":Conversion ERB vs HAML d'une condition if?
- 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
me fait:
app/views/layouts/application.html.haml:28: syntax error, unexpected kENSURE, expecting kEND
app/views/layouts/application.html.haml:30: syntax error, unexpected $end, expecting kEND
Alors que la logique
- 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
- end
me reçoit:
You don't need to use "- end" in Haml. Use indentation instead:
- if foo?
%strong Foo!
- else
Not foo.
Comment est-ce que j'obtiens ce conditi déclaration onal travaillant dans HAML?
Vous avez la réponse à votre question .... Le message d'erreur vous dit exactement ce qu'il faut faire. – nitecoder