X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Ftemplate%2FParserFilter.kt;h=cec5d5639c3b813c3c7dc5e8ff24b2ac14ba1094;hb=ffd92ca2374c0b2218e583d02e0bdd24b8c110ae;hp=4d2f9c1a123923defceb698191e5d6a386ad6a45;hpb=f6bb52d378645bf821febd6696bc69f250a92280;p=Sone.git diff --git a/src/main/kotlin/net/pterodactylus/sone/template/ParserFilter.kt b/src/main/kotlin/net/pterodactylus/sone/template/ParserFilter.kt index 4d2f9c1..cec5d56 100644 --- a/src/main/kotlin/net/pterodactylus/sone/template/ParserFilter.kt +++ b/src/main/kotlin/net/pterodactylus/sone/template/ParserFilter.kt @@ -7,11 +7,14 @@ import net.pterodactylus.sone.text.SoneTextParser import net.pterodactylus.sone.text.SoneTextParserContext import net.pterodactylus.util.template.Filter import net.pterodactylus.util.template.TemplateContext +import javax.inject.Inject +import javax.inject.Singleton /** * Parses a [String] into a number of [Part]s. */ -class ParserFilter(private val core: Core, private val soneTextParser: SoneTextParser) : Filter { +@Singleton +class ParserFilter @Inject constructor(private val core: Core, private val soneTextParser: SoneTextParser) : Filter { override fun format(templateContext: TemplateContext?, data: Any?, parameters: MutableMap?): Any? { val text = data?.toString() ?: return listOf() @@ -21,7 +24,7 @@ class ParserFilter(private val core: Core, private val soneTextParser: SoneTextP is Sone -> soneParameter else -> null } - val context = SoneTextParserContext(sone as? Sone) + val context = SoneTextParserContext(sone) return soneTextParser.parse(text, context) }