Skip to content

FreeMarker

templates_freemarker

This module provides an adapter for the templates Port supporting the Apache FreeMarker template engine.

Install the Dependency

1
2
3
4
5
repositories {
    mavenCentral()
}

implementation("com.hexagonkt:templates_freemarker:$hexagonVersion")
1
2
3
4
5
<dependency>
  <groupId>com.hexagonkt</groupId>
  <artifactId>templates_freemarker</artifactId>
  <version>$hexagonVersion</version>
</dependency>

How to Use

1
2
3
4
5
6
7
8
val contextVariables = hashMapOf(
    "contextVariableKey" to contextVariableValue
)
val renderedPage = FreeMarkerAdapter.render(
    "templates/page.html",
    Locale.getDefault(),
    contextVariables
)

If you have no context variables, you can simply pass an empty map:

1
2
3
4
5
val renderedPage = FreeMarkerAdapter.render(
    "templates/page.html",
    Locale.getDefault(),
    hashMapOf<String, Any>()
)

Packages

Name Summary
com.hexagonkt.templates.freemarker Classes defined in this package implement the Templates Port interface with the FreeMarker implementation.

Index

All Types

Comments