FLATE Library (Fast Template 1.5)
(c) Fabien MENEMENLIS (nihilist@dead-inside.org)

This program is released under the LGPL License. For copying information
see the file COPYING.


1. What is it all about?

This version is a somehow "new" implementation of Flate 1.4 that can deal
with multiple templates at the same time.


2. How do you install it?

It's fairly easy. From version 1.5, only C is supported, use previous versions
if you need perl support. 
Simply do a "make" in the root directory of the archive, the resulting library
(libflate.a) should be linked with your C cgi.
(gcc cgi.c -o cgi -L/path/to/Flate -I/path/to/Flate -lflate)


3. How does it work?

3.1. HTML code

There are no changes compared to version 1.4. checktpl can still be used
to validate a template.


3.2. CGI code

You first need to include "flate.h" in your program.

Each template object has to be declared with the type
Template *mytemplate = NULL;
It's important to initialize the variable to NULL because the first thing
templateSetFile() does it calling templateFreeMem() if the variable is
different from NULL. This prevents memory leaks if you call multiple times
templateSetFile() with the same object but will most likely crash if
mytemplate is not set to NULL.

templateSetFile(mytemplate, "template.html");
  this will load the file into memory and initialize the template.

templateSetVar(mytemplate, "variable", "value");
  this function will set ##variable## to "value".

templateSetVar(mytemplate, "myzone", "");
  is used to display a <!-- #BEGINZONE myzone --> <!-- #ENDZONE myzone -->
  block. If you don't call this function, the zone will not be displayed.

templateDumpTableLine(mytemplate, "dbline");
  will print the zone between #BEGINTABLE and #ENDTABLE, with the variables
  set before. Once printed, the variables are set to NULL again, you can
  reuse templateSetVar("variable", "value"); to set them for the next
  templateDumpTableLine("dbline");

Once you're done, you can use:
templatePrint(mytemplate);
  this will output the whole page (the result) to stdout.
or
buf = templatePage(mytemplate); (buf being a char *)
  this will dump the output in a buffer pointed by buf. You need to free(buf);
  after using this function.

templateFreeMem(template);
  will free all memory used by the template.


Thanks to Niraj Gupta for correcting issues on 1.5 with g++, fixing a free()
issue and making it -Wall compliant.

