package cow

  1. Overview
  2. Docs
module Tags : sig ... end
type t = Cow_xml.t
val stylesheet : string -> t

stylesheet style converts a COW CSS type to a valid HTML stylesheet

val table : ?flags:Tags.table_flags list -> row:('a -> t list) -> 'a list -> t

table ~flags:f ~row:r tbl produces an HTML table formatted according to f where each row is generated by passing a member of tbl to r.

  • parameter flags

    a list of type Cow.Html.Flags.table_flags specifying how the generated table is to be structured.

  • parameter row

    a function to transform a single row of the input table (a single element of the list, that is) into a list of elements, each of which will occupy a cell in a row of the table.

    tbl: a list of (probably) tuples representing a table.

    See the following example:

    let row = (fun (name,email) -> [ <:html<$str:name$>>; <:html<$str:email$>>]) in
    let data =
      \[ "Name","Email Address";
        "John Christopher McAlpine","christophermcalpine\@gmail.com";
        "Somebody McElthein","johnqpublic\@something.something";
        "John Doe","johndoe\@johndoe.com"; \] in
    let table = Cow.Html.Create ~flags:[Headings_fst_row] ~row data

    which produces the HTML table

    Name Email Address
    John Christopher McAlpine christophermcalpine\@gmail.com
    Somebody McElthein johnqpublic\@something.something
    John Doe johndoe\@johndoe.com

OCaml

Innovation. Community. Security.