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

Can JSX compile to a string instead of an object instantiation? #2335

Closed
trusktr opened this issue Oct 13, 2014 · 4 comments
Closed

Can JSX compile to a string instead of an object instantiation? #2335

trusktr opened this issue Oct 13, 2014 · 4 comments

Comments

@trusktr
Copy link

trusktr commented Oct 13, 2014

For example, can I opt for

var app = <Nav color="blue" />;

to convert to

var app = "<Nav color=\"blue\" />";

instead of

var app = Nav({color:"blue"});

?

@dashed
Copy link

dashed commented Oct 13, 2014

I don't think JSX can do this out of the box. Perhaps some macro with sweet.js? See: http://jlongster.com/Compiling-JSX-with-Sweet.js-using-Readtables

@syranide
Copy link
Contributor

React JSX(Transformer) probably never will, but other JSX implementations certainly can.

@zpao
Copy link
Member

zpao commented Oct 13, 2014

We're not going to do this. You are free to write your own transform if you'd like.

@zpao zpao closed this as completed Oct 13, 2014
@trusktr
Copy link
Author

trusktr commented Oct 13, 2014

@syranide Nice. I think sweet.js plus https://github.com/mxw/vim-jsx will do the job. :D

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

4 participants