class LinkedElementRenderFilter(private val templateContextFactory: TemplateContextFactory) : Filter {
companion object {
- private val loadedImageTemplate = """<a href="/<% link|html>"><span class="linked-element" title="<% link|html>" style="background-image: url('/<% link|html>')"></span></a>""".parse()
- private val notLoadedImageTemplate = """<span class="linked-element" title="<% link|html>" style="background-image: url('images/loading-animation.gif')"></span>""".parse()
+ private val loadedImageTemplate = """<%include linked/image.html>""".parse()
+ private val notLoadedImageTemplate = """<%include linked/notLoaded.html>""".parse()
private fun String.parse() = StringReader(this).use { TemplateParser.parse(it) }
}
--- /dev/null
+<a href="/<% link|html>"><span class="linked-element" title="<% link|html>" style="background-image: url('/<% link|html>')"></span></a>
--- /dev/null
+<span class="linked-element" title="<% link|html>" style="background-image: url('images/loading-animation.gif')"></span>
package net.pterodactylus.sone.template
import net.pterodactylus.sone.core.LinkedElement
+import net.pterodactylus.util.template.ClassPathTemplateProvider
import net.pterodactylus.util.template.HtmlFilter
import net.pterodactylus.util.template.TemplateContextFactory
import org.hamcrest.MatcherAssert.assertThat
init {
templateContextFactory.addFilter("html", HtmlFilter())
+ templateContextFactory.addProvider(ClassPathTemplateProvider(LinkedElementRenderFilter::class.java, "/templates/"))
}
private val filter = LinkedElementRenderFilter(templateContextFactory)