## Template system This is meant to be compatible with perls HTML::Template module. The following files can be used to use this implementation in other programs: * `buffer.c` * `buffer.h` * `template.c` * `template.h` ## Variable Setup See the header file `template.h` for functions aiding in setting up a `struct tmpl_data` structure to be used as an argument to the `tmpl_parse()` and `tmpl_parse_file()` functions. ## Tag Description ### Variables Usage: `` Replaced by the variable value from the current `struct tmpl_data` context. ### Loops Usage: `...` Implementation: The filter parser stores the position of the loop begin/end and calls a new instance of itself for each `struct tmpl_data` in the `struct tmpl_loop`. If no such data exists or the loop name was not found the parser continues after the `` tag. It is possible to build complex data structures with nested loops. ### Includes Usage: `` or `` Includes the "filename" as if it was part of the template to the output. Implementation: A new parser instance is generated with the files content and the current `struct tmpl_data` object is passed as the data structure. ### Conditions #### TMPL_IF Usage: `...` If the "identifier" references a loop the condition evaluates to `true` if the loop is not empty. If a variable is referenced the variable will evaluate to `false` if one of the following conditions apply: - Variable does not exist - Variable is empty - Variable contains the string '0' (zero) Implementation: The filter parser takes the `` tag and passes the range between those tags to a new instance of the parser with the current `struct tmpl_data`. In case of an `` belonging to the conditional block either the part before the `` or after the `` is parsed by passing the current `struct tmpl_data` object to a new parser instance. #### TMPL_UNLESS Usage: `...` Same as `TMPL_IF` but logically negated. #### TMPL_ELSE Usage: `......` Works the same way with `TMPL_UNLESS`. ## Notes Unless the perl HTML::Template module the name attribute is required exacactly in the form given above to simplify parsing.