Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jte tutorial provides invalid/confusing examples #241

Open
dzikoysk opened this issue Jul 27, 2023 · 0 comments
Open

Jte tutorial provides invalid/confusing examples #241

dzikoysk opened this issue Jul 27, 2023 · 0 comments

Comments

@dzikoysk
Copy link
Member

  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 javalin/javalin-rendering#23

  1. 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 javalin/javalin-rendering#23)

  1. Mention Gradle plugin:

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

  1. Bump Jte version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant