# Module Netcgi_modtpl

    module Netcgi_modtpl: sig .. end

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.

`type ``var =`

`|` | `VarString of `string`` | `(*` | ::tag:: | `*)`
`|` | `VarTable of `table_row list`` | `(*` | ::table(tag):: | `*)`
`|` | `VarConditional of `bool`` | `(*` | ::if(tag):: | `*)`
`|` | `VarCallback of `(string list -> string)`` | `(*` | ::call(f, x1,...):: | `*)`

    type table_row = (string * var) list

Variables are either simple string, tables, conditionals or callbacks.

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>`.

Tables are declared in the template by `::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 -> template

Compile the template from a named file. Not thread safe.

    val template_from_string : ?filename:string -> string -> template

Compile the template from a literal string. Not thread safe.

    val template_from_channel : ?filename:string -> Pervasives.in_channel -> template

Compile the template from a channel. Not thread safe.