All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hexagonkt.templates.rocker.RockerAdapter.kt Maven / Gradle / Ivy

There is a newer version: 3.7.2
Show newest version
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")
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy