javalin / javalin/website

Jte tutorial provides invalid/confusing examples

Open
#241 0 comments 4 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
39
Forks
98
PR merge metrics
No merged PRs in 30d

Description

1. > 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

It should reflect changes from https://github.com/javalin/javalin-rendering/issues/23

2. > 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)

3. Mention Gradle plugin:

https://github.com/casid/jte/blob/main/DOCUMENTATION.md#gradle

4. Bump Jte version

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.