mvel-ktx is a set of Kotlin extensions for MVEL
This repository is hosted via jitpack since it's by far the easiest delivery method while also being pretty transparent to the developer.
Make sure you have added jitpack to the list of your repositories:
maven("https://jitpack.io")
Then simply add the mvel-ktx
dependency
dependencies {
compile("com.github.vishna:mvel-ktx:master-SNAPSHOT")
}
val interpolatedString = """@{resultCount} results matching "@{query}"""".interpolate(mapOf(
"resultCount" to 256,
"query" to "kotlin"
))
print(interpolatedString) // prints "256 results matching "kotlin"
data class Foo(val bar: Int)
val sum : Int = """1 + 2 + bar""".eval(Foo(3))
println(sum) // prints "6"
For more documentation on API see mvel.kt and for more use examples see mvel_tests.kt