TyXML 4.0.0
Written by The Ocsigen Team on May 20, 2016

It is with great pleasure that we are announcing the release of TyXML 4.0.0. The major features of this new release are a new PPX syntax extension that allows to use the standard HTML syntax and an improved user experience for both old and new TyXML users.

What is TyXML ?

TyXML is a library for building statically correct HTML5 and SVG documents. It provides a set of combinators which use the OCaml type system to ensure the validity of the generated document. TyXML’s combinators can be used to build textual HTML and SVG, but also DOM trees or reactive interfaces, using Eliom and Js_of_ocaml.

New TyXML manual and improved documentation

A new TyXML manual is now available here. The documentation of the various TyXML modules was also improved. Do not hesitate to provide feedback via our bug tracker!

HTML syntax with the new PPX syntax extension

It is now possible to use the standard HTML syntax:

open Tyxml
let%html to_ocaml = "<a href='ocaml.org'>OCaml!</a>"

It supports insertion of OCaml code inside the HTML and can be used with all the TyXML modules (such as Js_of_ocaml and Eliom) and with SVG. A complete overview can be found in the manual.

This new PPX syntax extension leverages the (awesome) Markup.ml library and was contributed by Anton Bachin.

Others

  • Toplevel printers are now available for the base HTML and SVG implementations:
# Tyxml.Html.(div [pcdata "Oh!"]) ;;
- : [> `Div ] Tyxml.Html.elt = <div>Oh!</div>
  • The HTML and SVG combinators have received numerous improvements to make them more consistent and easier to use. This means that several modules and functions have been renamed and some types have been changed, which breaks compatibility with previous TyXML versions.

  • A healthy amount of new elements and attributes.

  • The full changelog is available here.

Compatibility

This new version breaks compatibility. Compatible versions of js_of_ocaml and Eliom are available in the respective master branches. A compatible js_of_ocaml version should be released shortly™.

TyXML 4.0.0 is only available on OCaml >= 4.02.

The future

While nothing is decided yet, some work has already started to enhance the syntax extension with type safe templating.

Happy HTML and SVG hacking!