coffee-react icon indicating copy to clipboard operation
coffee-react copied to clipboard

Comments in cjsx

Open jonywtf opened this issue 10 years ago • 12 comments

Can i use comments in html part of cjsx? Thanks!

jonywtf avatar Nov 16 '14 09:11 jonywtf

Official JSX doesn't support comments and I'm not particularly inclined to add <!-- html style comments --> to CJSX because they would have to be special-cased in the parser.

jsdf avatar Dec 05 '14 14:12 jsdf

It would be really nice to have some way of doing this — could we make {# foo } work?

ConradIrwin avatar Feb 18 '15 02:02 ConradIrwin

That wouldn't really make sense. Hash-comments go to the end of the line, so how would we differentiate a curly bracket which is just part of the comment from one which closes a coffeescript expression in JSX markup?

jsdf avatar Feb 18 '15 02:02 jsdf

I would add a special case for when the curly brace is at the end of the line. At the moment it's a syntax error, so it won't break anyone's existing code.

<ul>
  <li />
  {# blah'di'blah}
  <li />
</div>

ConradIrwin avatar Feb 18 '15 02:02 ConradIrwin

+1

braco avatar Mar 01 '15 22:03 braco

I've sent a pull request that implements my suggestion above, would love to get some feedback :).

ConradIrwin avatar Mar 02 '15 06:03 ConradIrwin

I'm not sure since when, but JSX does seem to support comments: http://facebook.github.io/react/docs/jsx-in-depth.html#comments

brumm avatar Mar 05 '15 20:03 brumm

Interesting. I'm in favour of implementing comments with the same semantics as JSX

jsdf avatar Mar 05 '15 22:03 jsdf

Would love to see the JSX comments added {/* comment */}

chasedeanda avatar May 06 '15 21:05 chasedeanda

@chasedeanda you can now use {# comment }, which does the same thing :)

ConradIrwin avatar May 06 '15 21:05 ConradIrwin

Thanks!

chasedeanda avatar May 06 '15 21:05 chasedeanda

Was hoping this would work for commenting multi-line JSX in CoffeeScript 2:

THREE POUND CHARACTERS JSX HERE THREE POUND CHARACTERS

but I get this error: image

remoteportal avatar Nov 25 '18 13:11 remoteportal