Goal
I would like to have this:< head > < title >a sample title< /title > < link href="style.css" type="text/css" rel="stylesheet" / > < script type="text/javascript" src="script.js">< / script > < / head >This would load one "style.css" file and one "script.js" from the HEAD tag.
Recipe
Static directory in configuration
There must be a "static" directory from where we load the static files.In the "ocsigen.conf" file:
< host > < site path="xxxx" > < static dir="/home/mihamina/public_html/static/" /> < eliom module="/xxx/xxx.cmo" /> < / site > < / host >
The (Da Mihamina) code :-)
open Lwt open XHTML.M open Eliom_services open Eliom_parameters open Eliom_sessions open Eliom_predefmod.Xhtml let main_handler sp () () = Lwt.return (html (head (title (pcdata "ttt")) [(css_link (make_uri (static_dir sp) sp ["style.css"]) ()); (js_script (make_uri (static_dir sp) sp ["script.js"]) ())]) (body [ (div [pcdata "blabla"]) ; (div [pcdata "blabla"]) ])) let main_service = Eliom_predefmod.Xhtml.register_new_service ~path: [""] ~get_params: Eliom_parameters.unit main_handler