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

com.kennycason.kakyll.view.template.TemplateEngineResolver.kt Maven / Gradle / Ivy

There is a newer version: 1.7
Show newest version
package com.kennycason.kakyll.view.render

import com.kennycason.kakyll.exception.KakyllException
import com.kennycason.kakyll.view.GlobalContext
import com.kennycason.kakyll.view.render.HtmlPageRenderer
import com.kennycason.kakyll.view.template.*
import org.apache.commons.io.FilenameUtils

/**
 * Determine which templates engine to use based on the configuration file.
 *
 * Only supports handlebars for now.
 */
class TemplateEngineResolver {
    private val templateEngines = mapOf(
            Pair("handlebars", HandlebarsTemplateEngine())
    )

    fun resolve(): TemplateEngine {
        val config = GlobalContext.config
        templateEngines[config.templateEngine]?.let { renderer ->
            return renderer
        }
        throw KakyllException("Could not find templates engine for [${config.templateEngine}]")
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy