Module Html


module Html: sig .. end
Generating HTML

type html = string 

Simple HTML


val h1 : ?atts:(string * string) list -> html -> html
val h2 : ?atts:(string * string) list -> html -> html
val h3 : ?atts:(string * string) list -> html -> html
val h4 : ?atts:(string * string) list -> html -> html
val h5 : ?atts:(string * string) list -> html -> html
val h6 : ?atts:(string * string) list -> html -> html
val pre : ?atts:(string * string) list -> html -> html
val string_for_html : string -> html
val justify_string_for_html : int -> string -> html
val text_area : string -> html
val justify_text_area : int -> string -> html
val tag : string -> ?atts:(string * string) list -> html -> html
tag t ~atts: [(attribute1, value1) ; (attribute2, value2) ; ...] html creates a html string where the given html is encapsultated in a new tag t, with the given attributes, in the form <t attribute1="value1" attribute2="value2" ...>html</t>. Note that there is no closing tag if it is not needed in HTML (for example : "br" tags).
val link : string -> ?target:string -> html -> html
link url html creates a html string representing a link in the form <a href="url">html</a>.
target : optional target value for the "target" attribute of the "a" tag.
val br : html
val p : ?atts:(string * string) list -> html -> html
val i : ?atts:(string * string) list -> html -> html
val b : ?atts:(string * string) list -> html -> html
val col : ?span:int -> ?cl:string -> ?w:string -> unit -> html
val tr : ?atts:(string * string) list -> html list -> html
val td : ?atts:(string * string) list -> html -> html
val table : ?w:string -> ?atts:(string * string) list -> html list -> html
val table_100 : ?atts:(string * string) list -> html list -> html
val ul : ?atts:(string * string) list -> html list -> html
val ul_li : html list -> html
val ol : ?atts:(string * string) list -> html list -> html
val ol_li : html list -> html
val span : ?cl:string -> ?atts:(string * string) list -> html -> html
val div : ?cl:string -> ?atts:(string * string) list -> html -> html
val seq : html list -> html
val concat : ?sep:html -> html list -> html

Complex HTML



CSS



type css_names = {
   section_table : string;
   section_title : string;
   subsection_table : string;
   subsection_title : string;
   elements : string;
   row : string array;
}
The css names used by complex documents.
val css_names : unit -> css_names
Return the current css names.
val set_css_names : css_names -> unit
Change the current css names.
val css_code : css_names -> string
Return the css code to use for the given css names, for the complex documents to look ok.

Complex documents


val frame_table : ?css:css_names ->
?title:string -> ?width:string -> html list -> html
frame_table rows builds a html string with the given rows in a table, using two tables to create a nice border. rows are lists of html strings which must contain the TD tags.
title : optional title
width : optional width for the top table (default is "100%")
val list_in_table : ?css:css_names ->
?sep:bool ->
?width:string ->
(html option * string option * string option * ('a -> html)) list ->
'a list -> html
list_in_table cols l builds a html string representing a list l, using HTML tables. cols are the column description, in the form (title option, class option, width option, f). f is apply to the element to get the content of the cell.
sep : indicate if we must insert space rows.
val double_list_in_table : ?css:css_names ->
?width:string ->
?title:string ->
((string * int) * (('a -> (string * html) list) * 'a list)) list ->
html
double_list_in_table [((title, span), (f, l)); ...] builds a html string representing a list of lists, using HTML tables. For each list we give the title, on how many columns the title spans, and a pair (f, l) as in the Html.list_in_table function.
title : the optional title for the list of lists.
val tree : 'a list -> ('a -> html) -> ('a -> 'a list) -> html
tree l f_html f_children creates a html string representing trees. The given list contains the roots of the trees. f_html returns the html string to insert fo each node, while f_children returns the list of the given node.
val tree_in_table : ?css:css_names ->
?width:string -> 'a list -> ('a -> html) -> ('a -> 'a list) -> html
Same as Html.tree but put the tree in a table.
val page : ?typ:string ->
?style:string -> ?more_head:string -> string -> html -> html
page title body creates a html string representing a HTML page, with the given title and body. The body does not contain the "body" tag so you can define a frameset, for example.
typ : indicateis the type of document. Default corresponds to XHTML 1.0 Strict.
style : use the style referenced by the given url
more_head : can be used to add HTML code to the header

Forms



type form_method =
| Get
| Post
| Post_multipart
val form : ?atts:(string * string) list ->
?met:form_method -> string -> html -> html
form ?method action body creates a form with the given method (default is Post) and action, containing the given body.
val submit_button : string -> html
submit_button label create a form submit button with the given label for the button.
val reset_button : string -> html
reset_button label create a form reset button with the given label for the button.
val select : ?atts:(string * string) list ->
string -> (string * string) list -> string -> html
select name choices default creates a select tag, to create a HTML combo in a form.
val textarea : ?atts:(string * string) list ->
?cols:int -> ?rows:int -> ?value:string -> string -> html
textarea ~value name creates a textarea tag, to create a HTML text area input field in a form. The field has the name name and the initial value value. The value string is escaped by the function to be displayed correctly.

type input_type =
| Text
| Checkbox
| Radio
| Password
| Submit
| Reset
| Hidden
| File
val input : input_type ->
?atts:(string * string) list ->
?size:string -> ?checked:bool -> ?value:string -> string -> html
input typ ?value varname creates a form field with given typ, using the given variable name varname, eventually adding a value for the value attribute if specified. The value string is escaped by the function, using Misc.escape_quotes and Misc.escape_entities.