package dream-html

  1. Overview
  2. Docs
include module type of Pure_html
type attr
type node
val to_string : node -> string
val to_xml : ?header:bool -> node -> string
val pp : Stdlib.Format.formatter -> node -> unit
val pp_xml : Stdlib.Format.formatter -> ?header:bool -> node -> unit
type !'a to_attr = 'a -> attr
type !'a string_attr = ('a, unit, string, attr) Stdlib.format4 -> 'a
type std_tag = attr list -> node list -> node
type void_tag = attr list -> node
type !'a text_tag = attr list -> ('a, unit, string, node) Stdlib.format4 -> 'a
val attr : string -> attr
val string_attr : string -> ?raw:bool -> 'a string_attr
val uri_attr : string -> 'a string_attr
val bool_attr : string -> bool to_attr
val float_attr : string -> float to_attr
val int_attr : string -> int to_attr
val std_tag : string -> std_tag
val void_tag : string -> void_tag
val text_tag : string -> ?raw:bool -> 'a text_tag
val txt : ?raw:bool -> ('a, unit, string, node) Stdlib.format4 -> 'a
val comment : string -> node
val (+@) : node -> attr -> node
val (-@) : node -> string -> node
val (.@[]) : node -> string -> string
val is_null : node -> bool
val is_null_ : attr -> bool
module HTML : sig ... end
module SVG : sig ... end
module MathML : sig ... end
module Aria : sig ... end
module Hx : sig ... end

Output

val respond : ?status:[< Dream.status ] -> ?code:int -> ?headers:(string * string) list -> node -> Dream.response Dream.promise
val send : ?text_or_binary:[< Dream.text_or_binary ] -> ?end_of_message:[< Dream.end_of_message ] -> Dream.websocket -> node -> unit Dream.promise

Type-safe wrapper for Dream.send.

  • since 3.2.0.
val set_body : Dream.response -> node -> unit

Type-safe wrapper for Dream.set_body. Sets the body to the given node and sets the Content-Type header to text/html.

val write : Dream.stream -> node -> unit Dream.promise

Type-safe wrapper for Dream.write.

val csrf_tag : Dream.request -> node

Convenience to add a CSRF token generated by Dream into your form. Type-safe wrapper for Dream.csrf_tag.

form
  [action "/foo"]
  [csrf_tag req; input [name "bar"]; input [type_ "submit"]]

Live reload support

module Livereload : sig ... end

Live reload script injection and handling. Adapted from Dream.livereload middleware. This version is not a middleware so it's not as plug-and-play as that, but on the other hand it's much simpler to implement because it uses type-safe dream-html nodes rather than parsing and printing raw HTML. See below for the 3-step process to use it.

OCaml

Innovation. Community. Security.