Module CamlTemplate


module CamlTemplate: sig .. end
A template processor.

Copyright © 2003, 2004, 2005 Benjamin Geer. Please see the file COPYING for licence information.

The latest version of this software can be found at http://saucecode.org/camltemplate.



Overview

To use templates, first write template source code (see the manual for instructions). Then create a template cache using the CamlTemplate.Cache module, and call CamlTemplate.Cache.get_template to create a CamlTemplate.template from your template source code.

To marge a template with data, put the data in a CamlTemplate.Model.thash. Then call CamlTemplate.merge.

Template Data Models


module Model: sig .. end
Provides the types used in the data models that are merged with templates.

Templates


type template 
Represents a parsed template.
val merge : tmpl:template ->
model:Model.thash -> buf:Buffer.t -> unit
Merges the data in a CamlTemplate.Model.thash with the template, and returns the resulting text in the buffer provided.
Raises Template_error if an error occurs in the template.
val get_name : template -> string
Returns the name of a template.
val dump : template -> string
Returns a simple string representation of the parse tree, for debugging purposes.

Exceptions


exception Syntax_error of string
Raised if an error is found when parsing template source code.
exception Template_error of string
Raised if an error occurs when merging data with a template.

Template Loading and Caching


module Cache: sig .. end
Caches templates.

Miscellaneous


val add_web_functions : Model.thash -> unit
Adds the following template functions to a template data model:

Each of these functions expects one argument.