[ANN] dream-html 1.0.0

Hi, dream-html 1.0.0 has been released to opam: dream-html 1.0.0 (latest) · OCaml Package

Repo: GitHub - yawaramin/dream-html: Generate HTML markup from your OCaml Dream backend server
API docs: Dream_html (dream-html.Dream_html)

Dream-html is a library for generating HTML, closely integrated with Dream. It can be used as an alternative to Dream’s built-in Embedded ML templating language. Here’s the Dream home page example using dream-html:

let hello who =
  let open Dream_html in
  let open HTML in
  html [] [
    body [] [
      h1 [] [txt "Hello, %s!" who]]]

let () =
  Dream.run
  @@ Dream.logger
  @@ Dream.router [Dream.get "/" (fun _ -> Dream_html.respond (hello "world"))]

In this release, I made a breaking change (hence major version bump) to group all HTML tags and attributes under the same HTML module, so only two opens are needed to access all HTML functionality directly.

Another smaller improvement is more granular escaping of HTML text nodes and attribute values, following browser rules more closely. E.g. I’m no longer escaping ' and " in text nodes, and not escaping &, <, > in attribute values.

More details in the repo readme and documentation. Enjoy!

17 Likes