Compile HTML templates into OCaml modules
Module type
Class type
Library weberizer
Module Weberizer . Path
type t

Path relative to a base directory.

val base : t
val from_base : t -> string

The (normalized) path to the filename (the filename being excluded) relative to the base directory. Returns "" if we are in the base directory.

val from_base_split : t -> string list

The path to the filename (including it) relative to the base directory splitted into its components (see Neturl for the precise format).

val filename : t -> string

The filename the path points to. The path designates a directory if and only if filename returns "".

val to_base : t -> string

The path from the directory of the filename to the base directory. One can see it as the "inverse" of from_base.

val in_base : t -> bool

in_base p returns true if p is the base directory or a file in the base directory.

val to_base_split : t -> string list

The path from the directory of the filename to the base directory. One can see it as the "inverse" of from_base_split.

val parent : t -> t

parent p returns the parent of p.

  • raises Failure

    if it is the base path.

val full : t -> string

Returns a path that can be used to open the file (or query the directory).

val language : t -> string

language p returns the language of the filename based on the convention that it has the form "name.lang.ext".

val description : t -> string

description p returns the descriptive name for the file pointed by p.

val concat_file : t -> string -> t
val navigation : t -> (string * string) list

navigation p returns the navigation information for the path p. It consists of a list of pairs (name, path) where name is a descriptive name of that directory of the path and path is the relative link to go from the location pointed by p to the directory. If filename p is of the form index.html or index.<lang>.html, then only its directory is included in the navigation information.

Descriptive names are based on the name of the directory or, if an index.<lang>.html file is present it is taken as its title (if any). <lang> is determined according to the file pointed by p (if of the form name.<lang>.html).

val translations : ?rel_dir:( string -> string -> string ) -> langs:string list -> t -> (string * string) list

translations langs p returns a list of couples (lang, url) for all translations of the file pointed by the path p. langs is the list of languages to examine, the first being the default one (files with no explicit language).

  • parameter rel_dir

    is a function so that rel_dir lang l gives the relative path from the base directory of the current language lang of the file p to the base directory of the translation in the language l. Default: fun _ l -> "../" ^ l.