-
Notifications
You must be signed in to change notification settings - Fork 1
HTML template files
The templating is handled by libctemplate. The capabilities that are supported in STL include:
<html>
<body>
<p>This is a test page</p>
<p>a = <TMPL_VAR name="a"></p>
<p>b = <TMPL_VAR name="b"></p>
</body>
</html>
Values are strings. The webserver.template()
function converts numeric values to strings automatically and with a default format. A row vector will be converted to a comma separated list.
<TMPL_IF name="a">
<p>a is exists in the structure.</p>
</TMPL_IF>
displays the program if the variable a
in the structure passed to webserver.template()
, exists and has a non-null value.
<TMPL_IF name="a" value="2">
<p>a exists in the structure and is equal to 2.</p>
</TMPL_IF>
displays the program if the variable a
in the structure passed to webserver.template()
, exists and is equal to 2.
An else-if and else clause is also supported
<TMPL_IF name="a">
<p>a exists in the structure.</p>
<TMPL_ELSE>
<p>a does not exist in the structure.</p>
</TMPL_IF>
<TMPL_IF name="a">
<p>a exists in the structure</p>
<TMPL_ELSEIF name="b"">
<p>a does not exist in the structure but b does.</p>
</TMPL_IF>
There is no limit on the number of TMPL_ELSEIF
statements. The HTML blocks can contain any combinations of HTML and Template tags, ie. you can have substitutions or if-statements.
<TMPL_INCLUDE name="filename">
The tag is replaced with the contents of template file filename and the result is expanded.