A feature to use the Pebble template engine with ktor.
Add to the repositories
block in the build.gradle
file:
maven { url "https://dl.bintray.com/jeffsmithdev/maven" }
Include the artifact:
compile 'com.tlogx.ktor:ktor-pebble:0.0.1'
Install the feature in ktor:
install(Pebble) {
install(Pebble) {
templateDir = "" // resource path, i.e templateDir = "templates/"
strictVariables = true // throw exception if variables are missing
defaultLocale = Locale.US // override Locale.getDefault()
}
}
When Pebble is configured, you can call the call.respond
method with a PebbleContent
instance:
routing {
get("/") {
val model = mapOf(
"title" to "Ktor Pebble Test Page",
"description" to "A Ktor feature to use the pebble template engine by Mitchell Bösecke",
"myDogs" to listOf("Bebe", "Dot", "Brownie", "Bella")
)
call.respond(PebbleContent("example.peb", model, "e"))
}
}
- Add additional pebble configuration options
0.0.1
- Basic functionality
- Most feature content taken from ktor-velocity
- Pebble template engine by Mitchell Bösecke