-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Feature wish: Support JSX syntax as part of the language #8802
Description
It would be awesome if ocaml would support JSX syntax out of the box. ReasonML has support for such syntax as part of the language and it make developing web front-end heavy applications easier and intuitive. Intuitive here means someone who is familiar with xml/html can immediately understands the view logic. Additionally it seems jsx syntax have other uses besides the web front-end programming, e.g. it is being used to develop a desktop GUI framework (https://github.com/revery-ui/revery, ), GUI Editor(oni2 -https://github.com/onivim/oni2), console output(https://reason-native.com/docs/pastel/) and reason-native(https://github.com/reasonml/ReasonNativeProject) to name a few.
Ocaml supporting this feature as part of the language itself (like ReasonML) would mean that one doesn't have to move to using the ReasonML to make use of JSX features. Ocaml is already a great language and adding JSX syntax sugar would make it a more appealing and viable option for these use cases.
After some investigation, the JSX syntax are converted to ocaml function application. For eg. the following JSX,
<div foo={bar}> child1 child2 </div>;
is converted
([@JSX] div(~foo=bar, ~children=[child1, child2], ()));
More information on ReasonML JSX: https://reasonml.github.io/docs/en/jsx
Is this a viable request?i.e. can it be implemented as part of an ocaml grammar? and is there an interest in this feature?