Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comments in cjsx #13

Open
jonywtf opened this issue Nov 16, 2014 · 12 comments
Open

Comments in cjsx #13

jonywtf opened this issue Nov 16, 2014 · 12 comments

Comments

@jonywtf
Copy link

jonywtf commented Nov 16, 2014

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

@jsdf
Copy link
Owner

jsdf commented Dec 5, 2014

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 jsdf closed this as completed Dec 5, 2014
@ConradIrwin
Copy link

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

@jsdf
Copy link
Owner

jsdf commented Feb 18, 2015

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?

@ConradIrwin
Copy link

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>

@braco
Copy link

braco commented Mar 1, 2015

+1

ConradIrwin added a commit to ConradIrwin/coffee-react-transform that referenced this issue Mar 2, 2015
Before this change it was not possible to comment inside CJSX templates.

* jsdf#40
* jsdf/coffee-react#13

After this change, you can use the syntax:

     {#this is a cjsx comment}

The syntax was designed to look like a CJSX_ESCAPE that contains a
comment, but as the resulting coffee-script would be illegal this is
special-cased by the parser to return nothing.

Future work would be needed make this syntax work inside a tag:

    <Person {#comment} />

or to make multiline comments work:

    <Person>{###

    ###}</Person>
@ConradIrwin
Copy link

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

@brumm
Copy link

brumm commented Mar 5, 2015

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

@jsdf jsdf reopened this Mar 5, 2015
@jsdf
Copy link
Owner

jsdf commented Mar 5, 2015

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

@chasedeanda
Copy link

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

@ConradIrwin
Copy link

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

@chasedeanda
Copy link

Thanks!

@remoteportal
Copy link

remoteportal commented Nov 25, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants