Module Mithril.M

type t

The main mithril object

val m : t

The global m object

module Children : sig ... end

The Children module tries to provide the flexibility of the Javascript API but in a type-safe manner by specifying exactly what can and cannot be passed to the Vnode generating function.

val v : ?⁠attr:Attr.t -> ?⁠children:Children.t -> string -> Vnode.t

v sel generates a vnode from a CSS selector sel

val v_comp : ?⁠attr:Attr.t -> ?⁠children:Children.t -> Component.t -> Vnode.t

v comp generates a vnode from a Component comp

val render : Brr.El.t -> Vnode.t list -> unit

render elt nodes renders nodes onto elt

val mount : Brr.El.t -> Component.t -> unit

mount elt comp activates the component, enabling it to auto redraw on events. See Component

val mount_vnode : Brr.El.t -> (unit -> Jv.t) -> unit
val redraw : unit -> unit

redraw () explicitly redraws the DOM.

val route : Route.route
module Request : sig ... end
module Jsonp : sig ... end
val parse_query_string : string -> Jv.t

Takes a query string such as "a=1&b=2" and returns an object {a : 1; b : 2}

val build_query_string : Jv.t -> string

The inverse of parsing -- takes an object {a : 1; b : 2} and produces a string "a=1&b=2"

module Pathname : sig ... end
val trust : string -> Vnode.t

trust html turns an HTML or SVG string into unescaped HTML of SVG -- the docs come with some warnings about this. By default Mithril escapes all values in order to prevent cross-site scripting (XSS) injections.

trust creates a Vnode.t from "trusted" HTML (or SVG) text -- this can be useful say if you use ocaml-omd to generate an HTML string from Markdown and want to embed it directly in your site.

val fragment : ?⁠attrs:Attr.t -> ?⁠children:Children.t -> unit -> Vnode.t

fragment allows you to attache lifecycle methods to a frgament vnode. A fragment Vnode represents a list of DOM elements. More information about fragments in the docs.