Module Weberizer.Binding
type t
Mutable value holding a collection of mappings from names of variables to their values (both being strings).
exception
Not_found of string
Not_found var
is raised if the variablevar
is not found in the binding.
val make : unit -> t
make()
returns a new empty collection of bindings.
val copy : t -> t
copy b
returns a new collection of bindings initially containing the same bindings asb
.
val string : t -> string -> string -> unit
string b var s
add to the bindingvar
->s
tob
.
val fun_html : t -> string -> (< content : html; page : html; > -> string list -> html) -> unit
fun_html b var f
add to the bindingvar
->f
tob
. At each occurrence ofvar
,f ctx args
will be executed and its output will replace current HTML tag (or its content, depending on whetherml:strip
was set or not).ctx
is an object giving some "context".ctx#content
is the html that is inside the tag and which is going to be replaced. It can be used as a structured argument.ctx#page
returns the whole HTML page — this can be useful to generate a table of content for example.
val fun_string : t -> string -> (< page : html; > -> string list -> string) -> unit
fun_string b var f
add to the bindingvar
->f
tob
. Seefun_html
for the arguments off
.
val on_error : t -> (string -> string list -> exn -> unit) -> unit
on_error b f
when a function associated to a variablev
applied to the argumentsa
raises an exceptione
, callf v a e
. The default value forf
prints an error onstderr
.