implements discussions
This commit is contained in:
parent
c46e401ef3
commit
cf0ad20c79
6 changed files with 203 additions and 24 deletions
21
src/template_utils.ml
Normal file
21
src/template_utils.ml
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
let get_title content =
|
||||
let open Soup in
|
||||
try
|
||||
let soup = content |> parse in
|
||||
soup $ "h1" |> R.leaf_text
|
||||
with Failure _e -> "Permap"
|
||||
|
||||
let render ?title content request =
|
||||
let title =
|
||||
match title with None -> get_title content | Some title -> title
|
||||
in
|
||||
Dream.html
|
||||
@@ Template.render_unsafe ~title:(Dream.html_escape title)
|
||||
~content:(Dream.html_escape content)
|
||||
request
|
||||
|
||||
let render_unsafe ?title content request =
|
||||
let title =
|
||||
match title with None -> get_title content | Some title -> title
|
||||
in
|
||||
Dream.html @@ Template.render_unsafe ~title ~content request
|
||||
Loading…
Add table
Add a link
Reference in a new issue