From 65f62a8b9e29d75674e1b1c060cb5af37b393b36 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Fri, 4 Aug 2017 17:05:25 -0400 Subject: [PATCH] Remove unnecessary replacements and newline removal --- src/main/kotlin/net/shadowfacts/ekt/EKT.kt | 4 ++-- src/test/kotlin/net/shadowfacts/ekt/Test.kt | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/net/shadowfacts/ekt/EKT.kt b/src/main/kotlin/net/shadowfacts/ekt/EKT.kt index ab75f2f..cd22154 100644 --- a/src/main/kotlin/net/shadowfacts/ekt/EKT.kt +++ b/src/main/kotlin/net/shadowfacts/ekt/EKT.kt @@ -20,7 +20,7 @@ object EKT { "#" to { s -> s + "/*" } ) - private val startStringRegex = Regex("(?:^|[^\\\\])([:=#])]\n?") + private val startStringRegex = Regex("(?:^|[^\\\\])([:=#])]") private val endStringRegex = Regex("\\[([:=#])") private val scriptPrefix = """ @@ -38,7 +38,7 @@ _result.toString() fun render(template: String, data: Map, dumpGeneratedScript: File? = null): String { @Suppress("NAME_SHADOWING") var template = template - template = template.replace("\"", "\\\"").replace("$", "\${'$'}") + template = template.replace("$", "\${'$'}") template = ":]$template[:" template = template.replace(startStringRegex, { val c = it.groups[1]!!.value diff --git a/src/test/kotlin/net/shadowfacts/ekt/Test.kt b/src/test/kotlin/net/shadowfacts/ekt/Test.kt index 96fbb11..65ede03 100644 --- a/src/test/kotlin/net/shadowfacts/ekt/Test.kt +++ b/src/test/kotlin/net/shadowfacts/ekt/Test.kt @@ -7,7 +7,9 @@ import java.io.File */ fun main(args: Array) { val res = EKT.render(File("template.ekt"), mapOf( - "value" to 11 + "title" to "EKT Test", + "body" to "some test content", + "value" to 42 ), dumpGeneratedScript = File("script.kts")) File("result.txt").apply {