Skip to content

Daikon Freemarker is a library that add to Daikon the ability to render Freemarker templates in the response

Notifications You must be signed in to change notification settings

DaikonWeb/daikon-freemarker

Repository files navigation

Daikon Freemarker

Daikon

Daikon Freemarker is a library that add to Daikon the ability to render Freemarker templates in the response. The main goals are:

  • Help in rendering a text or HTML in the response
  • Make integration with Freemarker very simple and easy

How to add Daikon Freemarker to your project

Gradle

  • Add JitPack in your root build.gradle at the end of repositories:
repositories {
    ...
    maven { url 'https://jitpack.io' }
}
  • Add the dependency
implementation('com.github.DaikonWeb:daikon-freemarker:1.9.0')

Maven

  • Add the JitPack repository to your build file
<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>
  • Add the dependency
<dependency>
    <groupId>com.github.DaikonWeb</groupId>
    <artifactId>daikon-freemarker</artifactId>
    <version>1.9.0</version>
</dependency>

How to use

HttpServer()
    .get("/") { _, res -> res.html("hello_to", hashMapOf("name" to "Bob")) }
    .start().use {
        val response = get("http://localhost:4545/")
        assertThat(response.headers["Content-Type"]).isEqualTo(TEXT_HTML_UTF_8.asString())
        assertThat(response.text).isEqualTo("hello Bob")
    }

Put your template file hello_to.ftl under the default directory src/main/resources/templates.

Template hello_to.ftl content:

hello ${name}

Resources

Authors

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details

About

Daikon Freemarker is a library that add to Daikon the ability to render Freemarker templates in the response

Resources

Stars

Watchers

Forks

Packages

No packages published