com.hexagonkt.templates.rocker.RockerAdapter.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of templates_rocker Show documentation
Show all versions of templates_rocker Show documentation
Template processor adapter for Rocker. Don't support dynamic template loading.
package com.hexagonkt.templates.rocker
import com.fizzed.rocker.Rocker
import com.fizzed.rocker.runtime.RockerRuntime
import com.fizzed.rocker.runtime.StringBuilderOutput
import com.hexagonkt.templates.TemplatePort
import java.net.URL
import java.util.*
class RockerAdapter(reloading: Boolean = false) : TemplatePort {
init {
RockerRuntime.getInstance().isReloading = reloading
}
override fun render(url: URL, context: Map, locale: Locale): String =
Rocker.template(url.file)
.bind("context", context)
.render(StringBuilderOutput.FACTORY)
.toString()
override fun render(
name: String, templates: Map, context: Map, locale: Locale
): String =
throw UnsupportedOperationException("Rocker does not support memory templates")
}