package net.pterodactylus.sone.utils
import net.pterodactylus.util.template.Template
+import net.pterodactylus.util.template.TemplateContext
import net.pterodactylus.util.template.TemplateParser
import java.io.StringReader
+import java.io.StringWriter
fun String.asTemplate(): Template = StringReader(this).use { TemplateParser.parse(it) }
+
+fun Template.render(templateContext: TemplateContext) =
+ StringWriter().use {
+ it.also {
+ render(templateContext, it)
+ }
+ }.toString()
import net.pterodactylus.sone.utils.jsonObject
import net.pterodactylus.sone.utils.let
import net.pterodactylus.sone.utils.parameters
+import net.pterodactylus.sone.utils.render
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.FreenetRequest
import net.pterodactylus.util.template.Template
-import net.pterodactylus.util.template.TemplateContext
-import java.io.StringWriter
/**
* This AJAX handler retrieves information and rendered representation of a [Post].
}.let { postTemplate.render(it) }
}
-
-private fun Template.render(templateContext: TemplateContext) = StringWriter().use { it.also { render(templateContext, it) } }.toString()