Generating Bratislava.pm.org using Template Toolkit - TT

Bratislava.pm.org is stored as a static html page on server. But HTML files are generated using Template. This Perl module allows to add special tags to a text file that are then parsed. By default the tags are [% %], but can be easily changed, to for example <? ?>, by setting [% TAGS <? ?> %].

Standard usage of Template Toolkit is in MVC frameworks, where it is used as a View that can generate XML, plain text, PDF, ... and of course HTML.

Except the direct usage in Perl script, Template Toolkit can be used also from command line. Using tpage we can convert files that have TT tags (.tt2) to a destination file (.html). Using ttree we can convert the whole file tree.

Templates that are used to generate Bratislava.pm.org are located in Subversion repository. Here we can find two files - Makefile and tt.cfg + three folders - html, tt, tt-lib.

In tt/ are the page bodies (.tt2) and static files (.css, .html, .jpg, ...). In tt-lib/ are the header and the footer of the pages.

The processing to HTML is done using "ttree -f tt.cfg". This command will take all .tt2 files and transforms them to .html + copies all the rest of the files to html/.

html/ folder is defined as svn:external pointing to Subversion repository. This way we can work on templates commit them, see the result and the changes that will be made to the real site can be seen using "svn diff". Final commit in html/ is made when everything is as it should be.

22. Apr 2008
Jozef