Hi, I have been working on a ‘simple’ OCaml library to generate HTML, with close integration with Dream. I am already using it on a side project and think it’s nearing production level for general use. I wanted to give a preview here in case anyone is interested.
- Repo: GitHub - yawaramin/dream-html: Generate HTML markup from your Dream backend server
- Doc: Dream_html (dream-html.Dream_html)
In terms of approach taken, it is closer to Webs_html than to TyXML. Things that are statically typechecked:
- ‘Standard’ tags have attributes and children
- Void elements have no children
- Some tags can contain only a single text node
- Attributes with boolean, int, or enumerated string values
- ‘Static’ in a sense:
<html>tag is always automatically prefixed with
All attributes and text nodes support format strings i.e. interpolation. So no need to pull in
Oh, one more thing. I also added the core htmx attributes since I’m using htmx.
Check out the test file for a slightly larger idiomatic usage: dream-html/test/dream_html_test.ml at main · yawaramin/dream-html · GitHub