Simplify some code
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 23 Apr 2017 15:23:20 +0000 (17:23 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 23 Apr 2017 15:23:20 +0000 (17:23 +0200)
src/main/kotlin/net/pterodactylus/sone/template/LinkedElementRenderFilter.kt

index e15f68b..a527a1d 100644 (file)
@@ -34,8 +34,7 @@ class LinkedElementRenderFilter @Inject constructor(private val templateContextF
                        StringWriter().use {
                                val templateContext = templateContextFactory.createTemplateContext()
                                templateContext["link"] = linkedElement.link
-                               loadedImageTemplate.render(templateContext, it)
-                               it
+                               it.also { loadedImageTemplate.render(templateContext, it) }
                        }.toString()
 
        private fun renderHtmlPage(linkedElement: LinkedElement) =
@@ -51,8 +50,7 @@ class LinkedElementRenderFilter @Inject constructor(private val templateContextF
                        StringWriter().use {
                                val templateContext = templateContextFactory.createTemplateContext()
                                templateContext["link"] = linkedElement.link
-                               notLoadedImageTemplate.render(templateContext, it)
-                               it
+                               it.also { notLoadedImageTemplate.render(templateContext, it) }
                        }.toString()
 
 }