To install the Jte plugin to your application, pass it to the install function in the specified module. The following examples show how to install Jte:
In an embeddedServer() function call.
In an explicitly defined module() extension function on the Application class.
Inside the install block, you can configure how to load JTE templates.
Configure Jte
Configure template loading
To load JTE templates, you need to:
Create a CodeResolver used to resolve template code. For example, you can configure DirectoryCodeResolver to load templates from a given directory or ResourceCodeResolver to load templates from application resources.
Use the templateEngine property to specify a template engine, which uses a created CodeResolver to transfer templates into native Java/Kotlin code.
For instance, the code snippet below enables Ktor to look up JTE templates in the templates directory: