package b0
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha512=00a6868b4dfa34565d0141b335622a81a0e8d5b9e3c6dfad025dabfa3df2db2a1302b492953bbbce30c3a4406c324fcec25250a00b38f6d18a69e15605e3b07e
doc/b0_b00_kit/B00_htmlg/El/index.html
Module B00_htmlg.El
Elements and HTML fragments.
Elements
The type for HTML fragments. A fragment is either character data or a single element or a sequence of elements.
v ?at n cs is an element with name n, attributes at (defaults to []) and children cs.
Except for At.class' the list at must not define an attribute more than once; this is not checked by the module. The At.class' is treated specially: multiple specifications are gathered to form a single, space separated, attribute value for the class HTML attribute.
val txt : string -> fragtxt d is character data d.
val sp : fragsp is El.txt " ".
val nbsp : fragnbsp is El.txt "\u{00A0}".
splice ?sep fs when added to a list of children in v splices fragments fs into the list, separating each fragment by sep (if any).
val void : fragvoid is splice [].
val raw : string -> fragraw s is the raw string s without escaping markup delimiters. This can be used to include foreign markup. s must be well-formed HTML otherwise invalid markup will be generated.
Output
val buffer_add : doc_type:bool -> Stdlib.Buffer.t -> frag -> unitbuffer_add ~doc_type b frag adds fragment frag. If doc_type is true an HTML doctype declaration is prepended.
val to_string : doc_type:bool -> frag -> stringto_string is like buffer_add but returns directly a string.
Convenience
val title_of_fpath : B0_std.Fpath.t -> stringtitle_of_fpath p is a page title for p guaranteed to be non empty. Either the basename of file without extension or if that results in "index" or "" the basename of the parent directory without extension or if that results in "", "Untitled".
val basic_page :
?lang:string ->
?generator:string ->
?styles:string list ->
?scripts:string list ->
?more_head:frag ->
title:string ->
frag ->
fragbasic_page ~lang ~generator ~styles ~scripts ~more_head ~title body is an El.html element with a At.lang attribute of lang (if specified and non-empty) containing a El.head element (see below) followed by body which must be a El.body element.
The other arguments are used to define the children of the page's El.head which are in order:
- A charset
El.metaof UTF-8 (unconditional). - A generator
El.metaofgenerator, if specified an non-empty. - A viewport
El.metawithwidth=device-width, initial-scale=1(unconditional). - A stylesheet
El.linkof typetext/cssfor each element ofstyles, in order (defaults to[]). - A
El.scriptwithAt.deferand ofAt.type'text/javascriptfor each element ofscripts, in order (defaults to[]). more_head(defaults toEl.void).- The page has a title
title, which must be non-white and and non-empty (falls back to"Untitled"in any of these cases).
val write_page :
?lang:string ->
?generator:string ->
?styles:string list ->
?scripts:string list ->
?more_head:frag ->
?title:string ->
B00.Memo.t ->
frag:B0_std.Fpath.t ->
o:B0_std.Fpath.t ->
unitwrite_page m ~frag ~o reads frag and inserts it in an El.body using raw and writes a full HTML document to o using basic_page (see doc of the corresponding arguments). If title is "" or unspecified page_title o is used.
Predefined element constructors
See the MDN HTML element reference.
Convention. Whenever an element name conflicts with an OCaml keyword we prime it, see for example object'.
The type for element constructors. This is simply v with a pre-applied element name.
The type for void element constructors. This is simply el with a pre-applied element name and without children.
val blockquote : consval figcaption : cons