Template Syntax

Basic syntax

A template file is built up with three things - blocks directives, variable directives and the layout information surrounding them.

Blocks are reusable components of a template which can be called to build up the final output from your document. For example, a news site may have a main block covering the entire document (called simply '/' in SimpleTemplate), a sideBox block for SlashBox style boxes, and an article block for news items:

   <html>
   <head><title>[[Title]]</title></head>
   <body>
   <table width=”90%”>
   <tr><td>
   [[block:sideBox]]
   <table>
   <tr><td>[[Title]]</td></tr>
   <tr><td>[[Body]]</tr></tr>
   </table>
   [[endblock]]
   </td>
   [[block:article]]
   <table><tr><td>[[Title]] by [[Author]]] on [[Date|gmdate(l jS M Y, g:ia T)]]</td></tr>
   <tr><td>[[Body|wrap()]]</td></tr>
   </table>
   [[endblock]]
   </body>
   </html>

This example shows usage of most of the features of SimpleTemplate - [[block:<name>]] and [[endblock]] define a new subblock, [[<name>]] defines the placement of a variable and [[<name>|function(arguments)]] applies the variable modifier function() to the variable.

Block declorations can (and indeed, should) be nested, and names can be repeated in different parts of the template provided they are not on the same level as each other - i.e. two blocks named “article” would be fine provided they were subblocks in two different blocks, e.g. “short” and “long”.

Variable modifiers

Variable modifers are filters that can be applied to variables to transform their contents into a more suitable form for that particular output format. Currently supported modifiers are: