let () =
+
+
let () =
Eliom_registration.Html.register ~service:myservice
(fun (myparam, _i) () ->
Lwt.return
Eliom_content.Html.F.(html (head (title (txt "The title")) [])
(body [h1 [txt myparam]])))
-
let () =
+
+
The service handler now takes as first argument something of type string * int
+
+
+
+
let () =
Eliom_registration.File.register ~service:myservice
(fun (_myparam, _i) () ->
Lwt.return "filename")
-
let () =
+
+
Services can return other types of content.
+
For example, we can return a file:
+
+
+
+
let () =
let a = ref 0 in
Eliom_registration.Action.register ~service:myservice
(fun (myparam, _i) () ->
a := a + 1;
Lwt.return ())
-
let () =
+
+
or an action.
+
Actions are services performing a side-effect.
+Handlers do not return any value.
+By default, the current page is regenerated.
+
+
+
+
let () =
Eliom_registration.Html.register ~service:myservice
(fun (myparam, _i) () ->
Lwt.return ([%html{|<html><head><title></title></head>
- <body><h1>Hello</h1></body>
+ <body><h1>Hello</h1></body>
</html>|})
-
let () =
+
+
A PPX extension provided by Tyxml makes it possible to use
+regular HTML syntax if you prefer
+
+
+
+
let () =
Eliom_registration.Html.register ~service:myservice
(fun (myparam, _i) () ->
Lwt.return
@@ -2058,7 +2113,7 @@
+