Chapter 3. Technical

The input directory is converted into some tree like data structure in the obvious way. The file nodes are substituted with data structures from inside those files. This big structure can be edited by the user and then every node of type "file" processed with proper template.

1.1. Templates

The program uses Template Toolkit templates library. Because each node has links to the parent and root nodes the template can use the entire structure. For example the 'par' subnode is a link to the node created from the parent directory. So

 [% par.file.title %] 
should evaluate to the title of article from file named "file" in the same directory. Elements that can be utilized in templates:

Additional elements present in nodes made from directories:

One more example:

[% FOREACH x = par.subdir.texts %]
[% x.value.title %]
[% END %]

The output shoul be a list of titles of articles found in the subdirectory 'subdir' of current directory.

1.2. Choosing templates for input files

There are three rules:

  • if there is a template with the base name identical to the basename of the input file the template is used with this file
  • if in some directory there is a template named default.tmpl than this template is a default template for that directory - i.e. applyied for all files that don't have individual templates
  • if in the directory there is not any default.tmpl than the default template for this directory is the default template for it's parent directory
As a consequence of those rules there should be always a default.tmpl file in the main source directory.

1.3. Schemas

Schemas are means for the administrator to define a list of possible structures for articles, and for supplying default data for them. The schemas are defined in the file named '_schema.dat' residing in the root source directory for the given project.