is JsonArray -> json.map { convertJson(it, currentFile) }
}
- private fun loadJsonContext(name: String): Any? =
+ private fun loadJsonContext(name: String): Map<*, *> =
File(Configuration.CurrentConfiguration.jsonDocDir).combineSafe("$name.json")
.takeIf { it.isFile }
?.let { file ->
if (data !is Map<*, *>)
error("JSON Object expected in file $name, got $text")
- data + PreParserFunctions.getFunctions()
- }
+ data
+ } ?: emptyMap<String, Any?>()
fun preparse(name: String, content: String): String {
return try {
val template = compiler.compile(content)
- val context = loadJsonContext(name)
+ val context = loadJsonContext(name) + PreParserFunctions.getFunctions()
template.execute(context)
} catch (ex: RuntimeException) {
application.log.warn("Runtime error pre-parsing factbook $name", ex)