package html_of_jsx

  1. Overview
  2. Docs
Render HTML writing JSX

Install

Dune Dependency

Authors

Maintainers

Sources

html_of_jsx-0.0.2.tbz
sha256=24dc2b9e3726b99d9b0d218289222e7ca66a7250432dc202ecc1b8da4efba0e7
sha512=c06d87f7e9208dcd7e0ff054c4f2c69d89711474d0da8a43496e3da46c3978a85471e750183fb423e7531efb9fbe5fa432a6729853e49d3226d5eb5ac39b459f

Description

Published: 29 Apr 2024

README

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, no htmlFor, no onChange, etc...)

  • Type-safe, validates attributes and their types (it can be better thought)

  • Minimal

    • Html_of_jsx.render to render an element to HTML

    • Jsx.* to construct DOM Elements and DOM nodes (Jsx.text, Jsx.int, Jsx.null, Jsx.list)

  • Works with Reason and mlx

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.

Dependencies (4)

  1. ppxlib > "0.23.0"
  2. reason >= "3.10.0"
  3. ocaml >= "5.0.0"
  4. dune >= "3.8"

Dev Dependencies (5)

  1. tiny_httpd with-test
  2. ocaml-lsp-server with-dev-setup
  3. ocamlformat = "0.26.1" & with-test
  4. odoc with-doc
  5. alcotest with-test

Used by

None

Conflicts

None

OCaml

Innovation. Community. Security.