Let’s try to render our first template. Create the directory src/main/jte in your project. In this directory create a file hello.jte and enter the following:
The guide points to "src/main/jte", like it'd be a new sources dir for Gradle/Maven, but to be more precise, it's a directory relative to the app's working directory. It means that if we'd change workdir of a given process, it won't work anymore like it was desired by tutorial & jte renderer author
This behavior is inconsistent with how other renderers work, so maybe it should be somehow highlighted with a note how to handle templates from resources
private fun createTemplateEngine(): TemplateEngine {
return if (isDevSystem) {
val codeResolver = DirectoryCodeResolver(Path.of("src", "main", "jte"))
TemplateEngine.create(codeResolver, ContentType.Html)
} else {
TemplateEngine.createPrecompiled(Path.of("jte-classes"), ContentType.Html)
}
}
Explain the difference between DirectoryCodeResolver/ResourceCodeResolver that is a key part for dev env. Explain that DirectoryCodeResolver handles relative path to local fs that depends on current workdir of app process (it may be needed once the src/resources/templates will become the default dir for jte renderer https://github.com/javalin/javalin-rendering/issues/23)
It should reflect changes from https://github.com/javalin/javalin-rendering/issues/23
Explain the difference between
DirectoryCodeResolver
/ResourceCodeResolver
that is a key part for dev env. Explain thatDirectoryCodeResolver
handles relative path to local fs that depends on current workdir of app process (it may be needed once thesrc/resources/templates
will become the default dir for jte renderer https://github.com/javalin/javalin-rendering/issues/23)https://github.com/casid/jte/blob/main/DOCUMENTATION.md#gradle