I am using haml to code out the following code. I basically have a bunch of nested if-else statements in my index.html.haml file. However I keep getting a syntax error for the code below.
- if current_user
:javascript
window.is_logined_in = true;
window.currentUserJSON = #{@current_user_json};
//Getting syntax error for the line below
- if window.currentUserJSON.user.following_count == 293 && window.currentUserJSON.user.answer_count == 276
window.complete_orientation = true;
- else
window.complete_orientation = false;
- else
:javascript
window.is_logined_in = false;

How can I modify my code to resolve this syntax error?
You can not use the
-prefix inside the:javascriptblock like this.You are literally writing the code to javascript and that’s causing the error,
but you should be able to do that without the prefixed
-, as it is already javascript.The javascript code itself is a bit verbose, but it should do the job.