module Netcgi_modtpl:Deprecated.Mod_caml style of templates. This template module is simple to use. It is here to provide a simple upgrade path from mod_caml. It should not be considered as the default template system of Netcgi.sig..end
type var =
| |
VarString of |
(* | ::tag:: | *) |
| |
VarTable of |
(* | ::table(tag):: | *) |
| |
VarConditional of |
(* | ::if(tag):: | *) |
| |
VarCallback of |
(* | ::call(f, x1,...):: | *) |
typetable_row =(string * var) list
A simple string is set with template#set "name" s where s
will be automatically escaped depending on the declaration in
the template:
::name:: does no escaping;::name_url:: escapes for URL encoding, make it suitable in a
link <a href="::name_url::">;::name_html:: escapes for HTML display of the string;::name_html_tag:: escapes the string to make it suitable to be
placed between quotes in an HTML tag, e.g.
<input value="::name_html_tag::">;::name_html_textarea:: escapes the string to make it suitable
to be placed between <textarea>...</textarea>.::table(name):: row
template ::end::. The row template can contain other
variables. Calling template#table "name" rows, where rows is
a list [row1, row2,...,rowN], will insert N row templates
with each template having its variables set thanks to row1,...
each of which is an associative list name -> value (of type
Template.table_row).
Conditionals are declared in the template by ::if(name)
.. ::else:: .. ::end:: with the "else" clause being optional.
Calling template#conditional sets up a conditional value.
Calling template#callback "fname" f sets up the callback
function declared by ::call(fname,arg1,...,argN):: replacing the
call by the value of f applied to the list [arg1,...,argN].
The string returned by f can be escaped by using suffices in the
template as for simple tags: ::call(fname,arg1,...,argN)_html::,...
A template may also include other templates with ::include(filename)::.
class template :?filename:string -> string ->object..end
new template ?filename tpl computes a new template from the
string tpl.
val template : string -> templateval template_from_string : ?filename:string -> string -> templateval template_from_channel : ?filename:string -> Pervasives.in_channel -> template