libtemplate template language description

The template language of libtemplate is very easy. It consists of a few keywords, some operators and HTML code.

Keywords

Operators

Syntax

general syntax

The template language is embedded into the HTML code. When the template engine sees a <$, it switches to parsing mode. Parsing mode ends when a $> has been seen outside a string. HTML code (outside parsing mode) is the same as <$ print $htmlcode; $>.

In parsing mode, every command has to be closed by a semi colon (like in C). A command consists of the command itself (if-then/else, print, include or function) and its arguments. For example, in if the command is if ... then ... endif; and the arguments are the condition and the if and else tree.

if-then/else

      if $var == "cde" then
        $var = "abc";
      endif;

      if $var == "abc" then
        $var = "cd";
      else
        $var = "3";
      endif;
    

print

      print $var."\n";
    

include

      include "filename";
      include "path/to/filename";
    

function

      function block1($param,$param1) {
        print "<td>".$param."</td><td>".$param1."</td>\n";
      }

      block1("blahr","blub");
    

Christian Kruse
Last modified: Wed Oct 9 15:44:44 CEST 2002