The template language of libtemplate is very easy. It consists of a few keywords, some operators and HTML code.
function
include
if
then
else
endif
print
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 $var == "cde" then $var = "abc"; endif; if $var == "abc" then $var = "cd"; else $var = "3"; endif;
print $var."\n";
include "filename"; include "path/to/filename";
function block1($param,$param1) { print "<td>".$param."</td><td>".$param1."</td>\n"; } block1("blahr","blub");