JAK

Introduction

Teng is a general purpose templating engine (whence Teng). Teng is primary a C++ library with easy--to--use API but it is also available (at least) as Python module and PHP extension.

Teng strictly separates application logic from presentation logic. Programmer writes code which fetches data (for example from database, application server etc.) and supplies them to the templating engine. Presentation coder (for example web designer) writes templates and doesn't bother about data origin. The only thing programmer and presentation coder must obey is that data structure must conform to the template.

Probably the most important use of Teng is generating HTML pages for web presentations. It is also wery useful for generating mail messages (but not spams).

Teng composes resulting text/page/file by combining input template with program supplied data together with (optional) configuration and localization (language) dictionary.

Localization support of Teng allows you to just write single template set for any number of supported languages.

Templates and dictionaries are cached by engine for further use.

Technicalities

Every template before page generation is compiled into so-called byte-code. Byte-code is sequence of instructions to Teng's engine--processor. During page generation, the engine executes instructions from byte-code and writes result to the output.

Every parsed dictionary and every compiled template is cached by the engine for further use. If the engine finds entry in cache for given combination <template, language dictionary, configuration> it then check every source file of template, language dictionary, configuration for change. When no change is found, the cached compiled template and dictionaries are used. Invalidated (sources have been changed or) entries are read and parsed before execution.

More precisely, there are two caches. One maps main dictionary filename to parsed dictionary (either language or configuration) and the other maps template key to compiled program. Template key is triplet (template, language dictionary, configuration); template is either template filename or MD5 computed from template itself (if source is from string).