javalin / javalin-rendering

Artifact/module for server-side template/markdown rendering in Javalin: https://javalin.io/plugins/rendering
Apache License 2.0
11 stars 7 forks source link

All renderers required in 5.3.0 #15

Closed orelinde closed 1 year ago

orelinde commented 1 year ago

Actual behavior (the bug) When using javalin-renderer 5.3.0 in combination with the JTE renderer. It requires me to add all "missing dependencies" of all the other renderers (commonmark, markdown....)

Expected behavior should work like in 5.2.0

To Reproduce Steps to reproduce the behaviour: POM.xml

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>17</maven.compiler.source>
    <maven.compiler.target>17</maven.compiler.target>
  </properties>

  <dependencies>
    <dependency>
      <groupId>io.javalin</groupId>
      <artifactId>javalin</artifactId>
      <version>5.3.0</version>
    </dependency>
    <dependency>
      <groupId>io.javalin</groupId>
      <artifactId>javalin-rendering</artifactId>
      <version>5.3.0</version>
    </dependency>
   <dependency>
       <groupId>org.slf4j</groupId>
      <artifactId>slf4j-simple</artifactId>
      <version>2.0.3</version>
    </dependency>
    <dependency>
      <groupId>gg.jte</groupId>
      <artifactId>jte</artifactId>
      <version>2.2.4</version>
    </dependency>
  </dependencies>

In Main

    public static void main( String[] args )
    {
        var app = Javalin.create(/*config*/)
                .get("/", ctx -> ctx.render("helloworld.jte"))
                .start(8080);

        JavalinJte.init();
    }

in /src/main/jte/helloworld.jte

<h1>Hello World!</h1>

Additional context When i downgrade the javalin-rendering version from 5.3.0 -> 5.2.0 everything works as expected.

tipsy commented 1 year ago

Thanks @orelinde, that's definitely a bug.

tipsy commented 1 year ago

Should be fixed here, please have a look: https://github.com/javalin/javalin-rendering/commit/a2a938d6d0f69111e018da416c80fd29f603a6ee

orelinde commented 1 year ago

Hi @tipsy , I checked out the code locally and tested with 5.3.1-SNAPSHOT and the rendering works again. I only get two Log entries telling me that .jte and .kte are already registered (I haven't seen those before)

image
tipsy commented 1 year ago

Glad it's working! The warning is because 5.3.0 will load them automatically, you can remove your "init" call ☺️

orelinde commented 1 year ago

That works! I removed the init call and those two lines don't appear anymore. Thank you for your fast reply and fix! 😄

tipsy commented 1 year ago

And thank you for reporting! ☺️

maj2c commented 1 year ago

Hi @tipsy, Thank you for the quick fix :) I confirm too that the javalin-rendering-5.3.1-SNAPSHOT.jar is working fine by me locally. Did not come across the info messages like orelinde did, I think because I am calling the init from within the Javalin.create.

tipsy commented 1 year ago

Thanks for testing!

I think because I am calling the init from within the Javalin.create.

You are correct, the warning will only be shown if init is called after Javalin has been started :)

tipsy commented 1 year ago

This has been released in 5.3.1 now !