pellest/src/template.ml

23 lines
668 B
OCaml
Raw Normal View History

2022-12-04 22:42:55 +01:00
open Tyxml
2022-12-06 00:12:14 +01:00
let generic ~page_title ~scripts content =
2022-12-04 22:42:55 +01:00
let open Html in
let head =
head
(title (txt page_title))
( [ link ~rel:[ `Icon ] ~href:"/assets/img/favicon.png" ()
; link ~rel:[ `Stylesheet ] ~href:"/assets/css/style.css" ()
]
@ scripts )
in
2022-12-06 00:12:14 +01:00
let body = body [ main [ div [ content ] ] ] in
2022-12-04 22:42:55 +01:00
let page = html head body in
Format.asprintf "%a@." (pp ~indent:true ()) page
2022-12-06 00:12:14 +01:00
let render ~title ~scripts content =
Dream.html @@ generic ~page_title:title ~scripts content
let err (status, msg) =
let code = Dream.status_to_int status in
Dream.html ~code @@ generic ~page_title:"Error" ~scripts:[] (Html.txt msg)