jte-models Facade Generator¶
jte-models is a generator extension for jte that creates a typesafe facade for rendering templates.
Setup¶
To use jte-models, set up your build script to include one of these:
Run the build to generate classes.
Full configuration
See details about how to fully configure the extension:
Output¶
Additional generated classes will include a facade interface named gg.jte.generated.precompiled.Templates
, with implementations:
gg.jte.generated.precompiled.StaticTemplates
gg.jte.generated.precompiled.DynamicTemplates
Templates
has a method for each of your templates, for example:
Tip
The package name can be changed by setting the packageName option in the build.
Usage¶
First, construct an instance of Templates
. If you are using a dependency injection framework, you could make a factory for this. Otherwise, use new StaticTemplates()
or new DynamicTemplates(templateEngine)
.
To use, call a template method to get a JteModel
object, then call one of its render
methods. For example:
Static vs. Dynamic¶
StaticTemplates
is built so that it calls directly to jte generated render classes, with no reflection used. This is good for a production build. It builds on the outputs of precompiled templates.
DynamicTemplates
delegates to a TemplateEngine
, so it can be set up to hot-reload templates. This is good for development. You will still have to rerun the build if @params of a template are changed.