Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

using comment above `else` bombs #931

Closed
trailsandtribulations opened this Issue · 10 comments

4 participants

@trailsandtribulations

the following bombs

//-first choice
if abc == 1
  h1 First Choice

//-second choice
else
  h1 Second Choice

if the comment "//-second choice" is removed, it works ok.

with comment in, get error SyntaxError: Unexpected token else

@vendethiel

And if you indent it ?

@trailsandtribulations
@vendethiel

It think the comment generates a DEDENT token, closing the if block, and that's why the else is not expected.
I agree comments could be chomped.

@trailsandtribulations
@ForbesLindesay

I agree that we have a lot of gotchas that really need fixing. I think in this case you may just have to indent the second comment though. Jade is very strict about indentation, which makes sense.

@trailsandtribulations
@joebalancio

This seems to be a personal coding-style that conflicts with Jade and not an actual bug. Maybe a Jade-compatible coding-standard needs to be written.

What about putting the same comments at the same indentation as h1?

if abc == 1
  //-first choice
  h1 First Choice
else
  //-second choice
  h1 Second Choice
@trailsandtribulations
@joebalancio

There are different styles of commenting too (another example below). I'm not saying that one is better than another. Whatever works for the developer(s) to best document and maintain the code. However, a specific style of coding shouldn't be forced upon a programming language.

// if late payment then show standard payment request and standard contact me
// else if amount is due then show standard payment notice and links for account history
// else customer has nothing due
if rcd.isPaymentLate()
  include payment-request
  include contact-me
else if rcd.isPaymentDue()
  include payment-notice
  include account-history-links
else
  include cat-picture
@trailsandtribulations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.