new modules for templates
This commit is contained in:
parent
6bb0d654df
commit
233a5ffc32
4
src/file.ml
Normal file
4
src/file.ml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
let of_filename f =
|
||||||
|
let open Lwt in
|
||||||
|
Lwt_io.(open_file ~mode:(Input) f >|= read_lines)
|
||||||
|
>|= (fun stream -> Lwt_stream.fold (^) stream "")
|
13
src/html.ml
13
src/html.ml
@ -23,17 +23,6 @@ let of_ymd ymd =
|
|||||||
|> Format.asprintf "%a" (Tyxml.Html.pp ())
|
|> Format.asprintf "%a" (Tyxml.Html.pp ())
|
||||||
|
|
||||||
let of_file_meta_pairs file_metas =
|
let of_file_meta_pairs file_metas =
|
||||||
let mustache_list =
|
|
||||||
let string s = prerr_endline ("string:"^s); s
|
|
||||||
and section ~inverted name contents = "section"
|
|
||||||
and escaped e = prerr_endline ("escaped:"^e); e
|
|
||||||
and unescaped u = u
|
|
||||||
and partial p = p
|
|
||||||
and comment c = c
|
|
||||||
and concat l = String.concat "," l in
|
|
||||||
Mustache.of_string "Hello world {{test}}"
|
|
||||||
|> Mustache.fold ~string ~section ~escaped ~unescaped ~partial ~comment ~concat
|
|
||||||
in
|
|
||||||
let link_item (y,m) = li [a ~a:[a_href (uri_of_string ("/text/" ^ Filename.chop_extension y))] [Unsafe.data Ymd.(m.title)]] in
|
let link_item (y,m) = li [a ~a:[a_href (uri_of_string ("/text/" ^ Filename.chop_extension y))] [Unsafe.data Ymd.(m.title)]] in
|
||||||
html (logarion_head "Homepage")
|
html (logarion_head "Homepage")
|
||||||
(body [
|
(body [
|
||||||
@ -41,7 +30,7 @@ let of_file_meta_pairs file_metas =
|
|||||||
div [
|
div [
|
||||||
h2 [pcdata "Articles"];
|
h2 [pcdata "Articles"];
|
||||||
ul (List.map link_item file_metas);
|
ul (List.map link_item file_metas);
|
||||||
pcdata mustache_list;
|
pcdata Template.(of_string "test {{test}}" |> fold);
|
||||||
];
|
];
|
||||||
])
|
])
|
||||||
|> Format.asprintf "%a" (Tyxml.Html.pp ())
|
|> Format.asprintf "%a" (Tyxml.Html.pp ())
|
||||||
|
17
src/template.ml
Normal file
17
src/template.ml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
let string s = prerr_endline ("string:"^s); s
|
||||||
|
let section ~inverted name contents = "section"
|
||||||
|
let escaped e = prerr_endline ("escaped:"^e); e
|
||||||
|
let unescaped u = u
|
||||||
|
let partial p = p
|
||||||
|
let comment c = c
|
||||||
|
let concat l = String.concat "," l
|
||||||
|
|
||||||
|
let of_string = Mustache.of_string
|
||||||
|
|
||||||
|
let of_file f =
|
||||||
|
let open Lwt in
|
||||||
|
Lwt_io.(open_file ~mode:(Input) f >|= read_lines)
|
||||||
|
>|= (fun stream -> Lwt_stream.fold (^) stream "")
|
||||||
|
|
||||||
|
let fold = Mustache.fold ~string ~section ~escaped ~unescaped ~partial ~comment ~concat
|
Loading…
x
Reference in New Issue
Block a user