Example: Calc application
<%args>
double arg1 = 0; // typed parameter with default value
double arg2 = 0; // typed parameter with default value
char op = ' '; // typed parameter with default value
method = "post"; // parameter with default type std::string
</%args>
<{ // <= this starts a c++-processing-block
double result = 0.0;
bool result_ok = true;
switch (op)
{
case '+': result = arg1 + arg2; break;
case '-': result = arg1 - arg2; break;
case '*': result = arg1 * arg2; break;
case '/': result = arg1 / arg2; break;
default: result_ok = false;
}
}> <# <= this terminates a c++-processing-block (and this is a ecpp-comment) #>
<html>
<head>
<title>Calculator</title>
</head>
<body bgcolor=#ffffcc>
<h1>Tommi's Tnt-Calculator</h1>
<form method=<$method$>> <# print value of a c++-variable #>
<# you can output other types as well - arg1 and arg2 are of type double.
They just need a outputstream-operator #>
<input type="text" name="arg1" value="<$arg1$>"> <br>
<input type="text" name="arg2" value="<$arg2$>"> <br>
<input type="submit" name="op" value="+">
<input type="submit" name="op" value="-">
<input type="submit" name="op" value="*">
<input type="submit" name="op" value="/">
% if (method == "get") { // '%' in the first column makes a c++-one-liner
<input type=hidden name=method value=get>
% }
</form>
% if (result_ok) {
<hr>
<$arg1$> <$op$> <$arg2$> = <$result$>
% }
</body>
</html>