package htmlit

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Htmlit v0.1.0

Htmlit provides simple but subtle combinators to generate HTML fragments and pages.

See the quick start.

Library htmlit

Quick start

Construct HTML fragments with the constuctors of the Htmlit.El module and render them to strings. Here's a simple example to get you started.

open Htmlit

let abbrs =
  [ "KISS", "Keep it simple, stupid";
    "DRY", "Don't repeat yourself" ]

let abbrify ?(at = []) (a, exp) = El.abbr ~at:(At.title exp :: at) [El.txt a]

let page ?(footer = El.void) ~title contents =
  let body = El.body [El.h1 [El.txt title]; contents; footer] in
  El.page ~lang:"en" ~title body

let mypage () =
  let comma = El.txt ", " in
  let abbrs = El.splice ~sep:comma (List.map abbrify abbrs) in
  let content = El.p [El.txt "Keep in mind: "; abbrs; El.txt "."] in
  page ~title:"Hints" content

let main () = print_endline (El.to_string ~doctype:true (mypage ()))

let () = if !Sys.interactive then () else main ()
OCaml

Innovation. Community. Security.