I'm trying to put some (non-rendering) comments inside an If / Else statement in one of my Haml views, but it seems to be causing problems.
I would like to have the following code:
-
Unfortunately, Rails raises this error:
Got "else" with no preceding "if"
If I remove the comment 'else', i.e.
- # Stuff like ______ activates the if statement - if @condition (Some code) - else (Some other code)
Everything works as intended. The problem is not the comment itself. I need to remove the actual Ruby line of code (including the hyphen) in order to get it for rendering. That is, even if I just leave an empty line preceded by a hyphen, for example:
- # Stuff like ______ activates the if statement - if @condition (Some code) - - else (Some other code)
I get the same error. Other potentially relevant details: now there is more code that is at the same level of indentation as the if / else statement (not inside it), and all this is nested inside the form. Can someone explain to me what is going wrong? Thank you very much!
PS This is my first SO question, so if I presented it improperly, let me know.
source share