LibCGI Template System




 Introduction
When a template system is used for web development, Web designers can work in parallel with C programmers to develop web sites, meaning that web page designers can focus solely on creating a site that looks good, and programmers can focus solely on writing top-notch code. The template system separates C code from the web pages, making the web site more maintainable over the long run.

The template system capabilities reach well beyond the realm of web sites; for example, it can generate SQL or XML documents, since the template language doesn't requires some specic file format to work with.

The template language is very simple to understand and to use, but offering great capabilities and flexibility the designing pages ( or some other kind of data ). While the specification is still in progress, here you will find all information about how it is structured and how it works. Other features are intead to the incorpored in the future, and changes may occur.

If you would like to contribute or have a suggestion, please do!

 1) Variables
Variables start with a dolar sign, can have 1 to 64 characters, are case-sensitive. Allowed characters are all alpha-numeric plus underscore. The variable ends when another variable is found, when the end-of-file is found, when a new line if found or when a white-space is found.
	
	$myVar
	$my_another_var
	$var_21
2)  Statements
2.1)  Creating variables
#set (expression)


Sets the value for a variable or create a new one. expression may be a single attribuition or the result of some arithmetic expression.
	
	#set ($my_var = "bleh")
	#set ($another_var = 3 * 4 + (5 - $numeric_var))
	#set ($one_more = "The total value is: "+ $value)
	#set ($name = "My Name")
	#set ($author = "The author's name is "+ $name)
2.2)  if-else
#if (condition)
	[...]
#elseif (condition)
	[...]
#else
	[...]
#end
condition is any valid boolean expression. Even if there is one single line into the statement, it must end with the #end keyworkd.
	
	#if (3 > 2)
		[...]
	#end
	#if (1 == 1 && 3 * 3 == 9)
		[..]
	#else
		[...]
	#end
	#if ($name == "My Name")
		[...]
	#elseif ($name == "Dude")
		[...]
	#elseif ($name == "Blah")
		[...]
	#end
2.3)  for loop
#for ($i = 0 to 10 [increment 1])
	[...]
#end
The sintax is a bit different from convencional for statements to make it clear to the non-programmer user ( aka designers ). It inits with a initial value for the value, then is followed by the to keyworkd and by the limit value. Optionally may be specified the increment range using increment form. By default is incremente by 1.

2.4)  Parsing files
#parse ("filename")
Includes some file, reading its contents and parsing any template diretive found.

2.5)  Including static data
#include ("filename")

Just includes some file, without trying to parse any kind of directives. Good for including static data.