weberizer
type html = Nethtml.document list
val compile_html :
?trailer_ml:string ->
?trailer_mli:string ->
?hide:string list ->
?module_name:string ->
string ->
unit
compile_html fname
reads the HTML template file fname
(typically a file with extension ".html") and creates an OCaml module with functions to fill the variables of the template. The module will be in files module_name
.ml and module_name
.mli.
compile fname
does the same as compile_html
except that trailer code is taken from fname
.ml and fname
.mli for the implementation and interface respectively. Moreover, to hide the signature of a template variable, say "var", one can add a comment (* \@hide var *)
in fname
.mli. Special annotations are added to the generated module implementation and interface so errors point back to fname
.ml and fname
.mli respectively.
module Binding : sig ... end
subst b html
return html
where all variables are substituted according to the bindings b
.
read fname
reads the file fname
and returns its content in a structured form.
Utilities
val write_html : ?doctype:bool -> ?perm:int -> html -> string -> unit
write_html html fname
writes the textual representation of the html
to the file fname
.
body_of html
returns the body of the HTML document or the entire document if no body is found.
val title_of : html -> string
title_of html
returns the title contained in html
(if no title is present, it will return ""
).
module Path : sig ... end
val iter_html :
?langs:string list ->
?exts:string list ->
?filter:( Path.t -> bool ) ->
?perm:int ->
?out_dir:( string -> string ) ->
?out_ext:( string -> string ) ->
string ->
( string -> Path.t -> html ) ->
unit
iter_html base f
iterates f lang file
on all HTML files under base
(the argument of f
is guaranteed to be a path to a file). The resulting HTML code is written under the directory out_dir lang
, the subpath begin the relative path of the file w.r.t. base
and the filename is the original one with the language removed.
relative_url_are_from_base path html
prefix all relative URLs in html
so that they are specified according to the directory given by path
instead of the base path.
email e
return some HTML/javascript code to protect the email e
from SPAM harvesters. The email e
may end with "?..." in order to specify options, e.g. ?subject=...
.
protect_emails html
changes all emails hrefs in html
in order to make it more difficult for spammers to harvest them.
module Cache : sig ... end
Simple cache with dependencies and timeout.