3.3. Templates

Templates are stored in the templates subdirectory of your module directory. Template files should be named the same as the CGI script that refers to them, with the extension changed to .tmpl. A template should exist for each CGI script in your module, except the action CGIs. They contain all the HTML code for the display of your module as well as special HTML::Template tags which are placeholders for variables you can set using the WebTool's templating functions (see Section 2.3.2).

There are several different HTML::Template tags that can be used. The <TMPL_VAR> tag replaces the tag with whatever value was set for it using the tmpl_set function, but there are also special tags to provide if/else branching and looping. See Appendix A for links to more information about the HTML::Template library.

<TMPL_VAR> tags are assigned a name in the template file. If this name begins with a lang_ prefix, it is automatically replaced by the matching entry in the modules appropriate language file. No English strings should ever be present in a template file, they should be entered in the language file and called with a <TMPL_VAR> tag.

Templates should use <DIV> tags and follow the layouts and CSS styles established by the existing WebTool modules.

<DIV CLASS="pageEntry">
  <DIV CLASS="pageEntryTitle"> 
    <TMPL_VAR NAME="lang_indextitle"> 
  </DIV>
  <DIV CLASS="pageEntryContent">
    <TMPL_VAR NAME="lang_indexintro">
  </DIV>
</DIV>