package html_of_jsx
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=24dc2b9e3726b99d9b0d218289222e7ca66a7250432dc202ecc1b8da4efba0e7
sha512=c06d87f7e9208dcd7e0ff054c4f2c69d89711474d0da8a43496e3da46c3978a85471e750183fb423e7531efb9fbe5fa432a6729853e49d3226d5eb5ac39b459f
README.md.html
README.md
html_of_jsx is an implementation of JSX designed to render HTML on the server, without React or anything else. It's a minimal library that allows you to write components of HTML in a declarative way.
Supports most of features from JSX (uppercase components, fragments, optional attributes, punning)
but with a few improvements (lowercase components, no need to add annotations)
No React idioms (no
className
, nohtmlFor
, noonChange
, etc...)Type-safe, validates attributes and their types (it can be better thought)
Minimal
Html_of_jsx.render
to render an element to HTMLJsx.*
to construct DOM Elements and DOM nodes (Jsx.text
,Jsx.int
,Jsx.null
,Jsx.list
)
Installation
opam install html_of_jsx
+ (library html_of_jsx.lib)
+ (preprocess (pps html_of_jsx.ppx))
Usage
let element = <a href="https://x.com/davesnx">
<span> {"Click me!"} </span>
</a>
let html: string = Html_of_jsx.render(element);
Check the demo/server.re file to see a full example.
Documentation
Check the Documentation to know more about the API and the features.
Credits
This library is extracted from server-reason-react and simplified to just work with HTML5.