How to add custom values in configuration files?

It is possible to add custom fields in configuration file for your own Eliom module. They must be inside tag <eliommodule>. Example:

      <eliommodule module="myproject.cma">

         <myoption myattr="bloh">blah</myoption>

      </eliommodule>

The module can access this data using function from module Eliom_config. Example:

(** Create a element of name and set ref v *)
let make_element name v =
  Ocsigen_extensions.Configuration.element
    ~name ?pcdata:(Some (fun s -> v := s)) ()

let logdir_ref = ref ""
let logdir_elt = make_element "logdir" logdir_ref

let datadir_ref = ref ""
let datadir_elt = make_element "datadir" datadir_ref

(** [parge_config] could be called just once *)
let () = Eliom_config.parse_config [logdir_elt; datadir_elt]

let logdir = !logdir_ref ^ "/"
let datadir = !datadir_ref ^ "/"


More details in documentation: Eliom_config

◄ Back to the Quick Howto's