Templates
Register Template Adapters
Example to show how to register template adapters.
full test.
Using regular Expressions
| TemplateManager.adapters = mapOf(
Regex(".*\\.html") to SampleTemplateAdapter("html"),
Regex(".*\\.txt") to SampleTemplateAdapter("text"),
Regex(".*") to SampleTemplateAdapter("others"),
)
|
Using globs
| TemplateManager.adapters = mapOf(
Glob("*.html").regex to SampleTemplateAdapter("html"),
Glob("*.txt").regex to SampleTemplateAdapter("text"),
Glob("*").regex to SampleTemplateAdapter("others"),
)
|
Process Templates
Simple example to show how to process templates.
full test.
| val context = mapOf("key1" to "value1", "key2" to "value2")
val rendered = TemplateManager.render(urlOf("classpath:template.txt"), context)
|