wiki:Doc/panc/templates

Templates

A machine configuration is defined by a set of files, called templates, written in the pan language. These templates define simultaneously the configuration parameters, the configuration schema, and validation functions. Each template is named and is contained in a file having the same name.

The syntax of a template file is simple:

[ object | declaration | unique | structure ] template template-name;
[ statement ... ]

These files may contain comments that start with the hash sign ('#') and terminate with the next new line or end of file. There are five different types of templates that are identified by the template modifier.

Object Templates

An object template is declared via the 'object' modifier. Each object template is associated with a machine profile and the pan compiler will, by default, generate an XML profile for each processed object template. An object template may contain any of the pan statements. Statements that operate on paths may contain only absolute paths.

Object template names may not be namespaced; that is, they may not contain the '/' character. For the automatic loading mechanism to find object templates, the directory containing them must be specified explicitly in the load path (either on the command line or via the LOADPATH variable).

Ordinary Templates

An ordinary template uses no template modifier in the declaration. These templates may contain any pan statement, but statements must operate only on absolute paths.

Declaration Templates

A template declared with a 'declaration' modifier is a declaration template. These template may contain only those pan statements that do not modify the machine profile. That is, they may contain only type, bind, variable, and function statements. A declaration template will only be executed once for each processed object template no matter how many times it is included. It will be executed when the first include statement referencing the template is encountered.

Unique Templates

An 'unique' template behaves like an ordinary template except that it will only be included once for each processed object template. It has the same restrictions as an ordinary template. It will be executed when the first include statement referencing the template is encountered.

Structure Templates

A structure template may only contain include statements and assignment statements that operate on relative paths. The include statements may only reference other structure templates. Structure templates are an alternative for creating nlists (or hashes) and are used via the create() function.

Last modified 17 years ago Last modified on Mar 7, 2007, 7:10:05 PM