package html_of_jsx

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Declaratively create HTML elements with JSX using OCaml/Reason.

let html: string = JSX.render (
  <div>
    <h1> {JSX.string("Hello, World!")} </h1>
  </div>
)
module Attribute : sig ... end
type element

The type that represents a JSX.element

val render : element -> string

Render a JSX.element to a string.

let html: string = JSX.render (
  <div>
    <h1> (JSX.string "Hello, World!") </h1>
  </div>
)
val float : float -> element

Helper to render a float

val fragment : element list -> element

Fragment

val int : int -> element

Helper to render an integer

val list : element list -> element

Helper to render a list of elements

val node : string -> Attribute.t list -> element list -> element

The function to create a HTML DOM Node https://developer.mozilla.org/en-US/docs/Web/API/Node. Given the tag, list of attributes and list of children.

JSX.node(
  "a",
  [JSX.Attribute.String(("href", "https://ocaml.org"))],
  [JSX.string("OCaml")],
);
val null : element

Helper to represent nullability in JSX, useful to pattern match

val string : string -> element

Helper to represent an element as a string

val text : string -> element

Helper to render a text

  • deprecated Use JSX.string instead
val unsafe : string -> element

Helper to bypass HTML encoding and treat output as unsafe. This can lead to HTML scaping problems, XSS injections and other security concerns, use with caution.

module Debug : sig ... end

Provides ways to inspect a JSX.element.

OCaml

Innovation. Community. Security.