Use Ocsigen toolkit widgets

I wanted to try the Ocsigen toolkit widgets so I generated a little test with :

eliom-distillery -name test -template basic.ppx -target-directory test

Then I added this ocsigen-toolkit.client in the Makefile.options at the line :

CLIENT_PACKAGES := lwt.ppx js_of_ocaml.ppx js_of_ocaml.deriving.ppx ocsigen-toolkit.client

And here is my test.eliom file :

[%%shared
    open Eliom_lib
    open Eliom_content
    open Html.D
    open Lwt
]

module Test_app =
  Eliom_registration.App (
    struct
      let application_name = "test"
      let global_data_path = None
    end)

let cal = Ot_calendar.make ()

let page () =
  html
    (head (title (pcdata "Test")) [])
    (body [h1 [pcdata "Test"];
           cal ])


let main_service =
  Test_app.create
    ~path:(Eliom_service.Path [])
    ~meth:(Eliom_service.Get Eliom_parameter.unit)
    (fun () () ->
       Lwt.return (page ())
    )

And of course, it don’t work. I have the following message : Error: Unbound module Ot_calendar

Adding ocsigen-toolkit.server to SERVER_PACKAGES should make it work :).
(note also that, at least here, the calendar creation function is Ot_calendar.make, not Ot_calendar.create)

1 Like

Adding ocsigen-toolkit.server to SERVER_PACKAGES should make it work :).

You are right, it works with this.

the calendar creation function is Ot_calendar.make

And for this too you are right :slight_smile: . My calendar is not shown but I will try to find out myself and maybe create another question.

thanks

Ah, this is probably because here you create the calendar widget once at the toplevel, while it should be created when creating the page contents. In other words, removing the let cal = ... and defining page as:

let page () =
  html
    (head (title (pcdata "Test")) [])
    (body [h1 [pcdata "Test"];
           Ot_calendar.make () ])

seems to work… :slight_smile: