is a 'pure Java' template engine and can be used to generate output in any
(text-)format (f.e. web pages, source code, SQL, ...).
It can be used either as a standalone utility or as an integrated component of other systems.
Templates is fully configurable
and pretty easy to learn.
It's technology is similar to Sun's JSP(TM) and if you are familiar with that you might find the Comparison to JSP
Why another generator? The answer is simple:
When I wrote the first version of Templates in 1999,
there were no present tools that easily and fully fit my needs. So I wrote my own and improved it over years while
using it in many projects. The JTools version is a completely redesigned generation. Even if there are now some similar Open Source tools available,
Templates seems to be the most powerfull and flexible in it's scope of application for me.
A Template is an archetype for the generation of "similar" output.
Beneath the purposed output language, the Template is composed of a control language.
The output generation is done by Template Engines.
They can be divided in two groups:
- Single-Phase-Engines are parsing the templates and generating the output in one step.
They have typically a proprietary control language.
Two-Phase-Engines are doing this in two steps.
In the first step they are parsing the template and create a generator code.
In the second step they are using this generator code to produce.
The control may be served by the programming language of the generator code.
A third syntax is required to different between the elements of the the output language
and the generator code language. It is called Template Control Language.
The Template Compiler (TmplC)
implements the first
phase of a Two-Phase-Engine.
The Templet Execution Framework (TEF)
is a possibility
to execute the second phase.
The Principle of Two-Phase Template Engines
A Template is written in an arbitrary output language with configurable control tags.
It might contain macro calls and/or Java code to control the generated Templet's behaviour as well as other included Templates.
It will be successively compiled by a Template Compiler and a Java Compiler into a Templet.
A Templet is a Java classfile that comprises a method
public void execute(java.io.PrintStream out) that writes the output to out.
It might have arbitrary additional methods, properties, superclasses and implemented interfaces.
All - by default - generated methods are omittable (without the execute-method) and renameable.
It can be executed by
- just calling the execute-method,
- using an execution framework like TEF (may be in an Ant build process),
- calling a public static void main(String) method (can be automatically generated with a macro) or
- a custom execution method.
Execution typically results in one or many files (resp. streams).