1 package net.pterodactylus.sone.web.page
3 import net.pterodactylus.util.template.*
7 class TemplateRenderer @Inject constructor(private val templateContextFactory: TemplateContextFactory) {
9 fun render(template: Template, processor: (TemplateContext) -> Unit = {}): String =
10 templateContextFactory.createTemplateContext().let { templateContext ->
11 templateContext.mergeContext(template.initialContext)
12 processor(templateContext)
13 StringWriter().also { template.render(templateContext, it) }.toString()