![]() |
![]() |
![]() |
CTPL Reference Manual | ![]() |
---|
CTPL supports 2 kind of data:
Raw data |
The actual content of your template, or at least most of it: unparsed data that will remain unchanged. |
Template blocks |
The instructions that makes the template engine useful. |
There is no syntax for the raw data: everything that is not a
template block is raw data. The only exception to this rule is that
the template-blocks-delimiters {
and }
must be escaped using a backslash (\
). For example, to
produce a opening bracket, you need to write \{
.
Template blocks are delimited with brackets: they are opened with an
unescaped opening bracket ({
) and closed with an
unescaped closing bracket (}
). All data inside these two
brackets is template instructions.
There is 3 instruction types:
The |
The The syntax is the following:
|
||
The |
The The syntax is the following:
If the |
||
An expression |
An expression that will be replaced by its computation result. See CtplLexerExpr for details on the syntax of expressions. Basically, it may be any mathematical-like expression that may include reference(s) to variable(s). |
Example 2. Short template
1 2 3 |
{for i in array}
{i}
{end} |
This example will output each item of array
on a
newline. Supposing the array [1, 2, 3]
, the output will
be:
1 2 3 4 5 |
1 2 3 |
Example 3. Longer template
Here what may be a template for a member list HTML page:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<html> <head> <title>Member list</title> </head> <body> <h1>List of our members<h1> <ul class="memberlist"> {for member in members} <li>{member}</li> {end} </ul> </body> </html> |