+ base
+
+(* Cache of precompiled templates, arranged by full path. *)
+let cache = Hashtbl.create 32
+
+let _get_template filename =
+ let path = base // filename in
+ let stat = Unix.stat path in
+ let mtime = stat.st_mtime in
+
+ try
+ let template, old_mtime = Hashtbl.find cache path in
+ if old_mtime < mtime then (
+ (* The template has changed on disk since it was compiled. Reload. *)
+ let template = Template.template path in
+ Hashtbl.replace cache path (template, mtime);
+ template
+ ) else
+ template
+ with
+ Not_found ->
+ (* Template not seen before, so load it. *)
+ let template = Template.template path in
+ Hashtbl.replace cache path (template, mtime);
+ template
+
+let get_template (dbh : Dbi.connection) hostid filename =
+ let template = _get_template filename in
+
+ (* Get standard fields concerning this host from the database. *)
+ (* XXX *)
+
+ template