This example shows how to add Rocker to a Javalin app.
First one needs to add the Rocker runtime to their dependencies. For maven it looks something like this:
<dependencies>
<dependency>
<groupId>com.fizzed</groupId>
<artifactId>rocker-runtime</artifactId>
<version>${rocker.version}</version>
</dependency>
<!-- for hot-reloading support only during development -->
<dependency>
<groupId>com.fizzed</groupId>
<artifactId>rocker-compiler</artifactId>
<version>${rocker.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
Replace ${rocker.version} with the current version of Rocker. See Rocker on maven central for more details.
See the official Rocker readme for details on how to do this. Rocker also supports Gradle.
Add the following line to the sourceDirs configuration of the Kotlin Maven plugin:
<sourceDir>${project.basedir}/target/generated-sources/rocker</sourceDir>
As of Javalin 4 there is no support for double extension files. The extension .html
is used for the integration. This overrides Javalin's support for Thymeleaf.
For everything to work correctly template files have to end in with .rocker.html
.