Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Parse <Foo.bar /> elements #125

Merged
merged 2 commits into from
Sep 7, 2020

Conversation

jchavarri
Copy link
Contributor

Found in #124.

Reason parser used to parse JSX elements like <Foo.bar />:
https://astexplorer.net/#/gist/e21abaf96358b68be3ed3da19930be58/32e083720817c639502960b54984dff8396a3f7b.

React ppx also builds on top of this to allow custom make names, e.g.

let t = <Foo.bar />
let t = <Foo.Bar />

is transformed into:

let t = React.createElement(Foo.bar, Foo.barProps()); /* We can call `bar` instead of `make` */
let t = React.createElement(Foo.Bar.make, Foo.Bar.makeProps());

(shameless plug, can be tested in https://jchavarri.github.io/ppx-explorer/ 😜 )

@@ -20,6 +20,7 @@ let _ = <div className="menu" onClick={_ => Js.log("click")}></div>

let _ = <Navbar> </Navbar>
let _ = <Nav.Navbar> </Nav.Navbar>
let _ = <Nav.navbar> </Nav.navbar>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add more test cases? Nested, self closing etc.
Can you also test cases for the printer in tests/printer/expr/jsx.js?
Can you also add a test case in tests/parsing/errors/expression/jsx with an error in the closing "name"?
<Nav.navbar> </Nav.foo>?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @IwanKaramazow, added in 6987427.

@IwanKaramazow IwanKaramazow merged commit 8f78fcb into rescript-lang:master Sep 7, 2020
@IwanKaramazow
Copy link
Contributor

@jchavarri Muchas gracias!

@jchavarri jchavarri deleted the jsx-uident-lowercase branch September 20, 2020 16:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants