Tiny_httpd_html
HTML combinators.
This module provides combinators to produce html. It doesn't enforce the well-formedness of the html, unlike Tyxml, but it's simple and should be reasonably efficient.
module Out : sig ... end
Output for HTML combinators.
type elt = Out.t -> unit
A html element. It is represented by its output function, so we can directly print it.
Element with children, represented as a list.
A chunk of sub-elements, possibly empty.
Element with children, represented as a list of sub_elt
to be flattened
val sub_seq : elt Stdlib.Seq.t -> sub_elt
Sub-element with a sequence (Seq.t
) of items inside.
val seq_of_array : 'a array -> 'a Stdlib.Seq.t
Helper to build a Seq.t
from an array.
val sub_empty : sub_elt
Sub-element with nothing inside. Useful in conditionals, when one decides not to emit a sub-element at all.
val txt : string -> elt
Emit a string value, which will be escaped.
val txtf : ('a, Stdlib.Format.formatter, unit, Out.t -> unit) format4 -> 'a
Formatted version of txt
val raw_html : string -> elt
Emit raw HTML. Caution, this can lead to injection vulnerabilities, never use with text that comes from untrusted users.
tag "menuitem", see mdn
tag "caption", see mdn
tag "caption", see mdn
tag "figcaption", see mdn
tag "figcaption", see mdn
tag "footer", see mdn
tag "footer", see mdn
tag "menu", see mdn
tag "menu", see mdn
tag "nav", see mdn
tag "nav", see mdn
module A : sig ... end
Attributes.
val to_output : ?top:bool -> elt -> Tiny_httpd_core.IO.Output.t -> unit
Write an HTML element to this output.
val to_string : ?top:bool -> elt -> string
Convert a HTML element to a string.
val to_string_l : elt list -> string
Convert a list of HTML elements to a string. This is designed for fragments of HTML that are to be injected inside a bigger context, as it's invalid to have multiple elements at the toplevel of a HTML document.
val to_string_top : elt -> string
val to_out_channel_top : elt -> Tiny_httpd_core.IO.Output.t -> unit
Write a toplevel element to an output channel.
val to_writer : ?top:bool -> elt -> Tiny_httpd_core.IO.Writer.t
Produce a streaming writer from this HTML element.
val to_stream : elt -> Tiny_httpd_core.IO.Input.t
Convert a HTML element to a stream. This might just convert it to a string first, do not assume it to be more efficient.