https://github.com/limebeck/ko-te
Ko(tlin)-Te(mplate engine). Kotlin Multiplatform Template Engine (WIP)
https://github.com/limebeck/ko-te
kotlin kotlin-multiplatform kotlin-native template-engine
Last synced: 3 months ago
JSON representation
Ko(tlin)-Te(mplate engine). Kotlin Multiplatform Template Engine (WIP)
- Host: GitHub
- URL: https://github.com/limebeck/ko-te
- Owner: LimeBeck
- License: mit
- Created: 2021-11-25T09:45:08.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-11-26T19:13:02.000Z (over 2 years ago)
- Last Synced: 2025-02-01T23:51:06.346Z (3 months ago)
- Topics: kotlin, kotlin-multiplatform, kotlin-native, template-engine
- Language: Kotlin
- Homepage:
- Size: 185 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.MD
Awesome Lists containing this project
README



[](https://search.maven.org/search?q=g:%22dev.limebeck%22%20AND%20a:%22ko-te%22)# Ko-te (Kotlin Template Engine)
Pure-kotlin template engine for all platforms
## Example
```kotlin
import dev.limebeck.templateEngine.KoTeRenderer
import kotlin.test.assertEqualsval renderer = KoTeRenderer()
val simpleTextTemplate = """
Hello, {{ name }}!
Object value: "{{ object.value[0] }}"
""".trimIndent()val data = mapOf(
"name" to "World",
"object" to mapOf(
"value" to listOf("Simple string")
)
)val expectedOutput = """
Hello, World!
Object value: "Simple string"
""".trimIndent()assertEquals(expectedOutput, renderer.render(simpleTextTemplate, data).getValueOrNull())
```## Reference template
```
Variable access: {{ variable }}
Key access: {{ object.value }}
Index access: {{ array[0] }}
Function call with round brackets syntax: {{ uppercase(variable) }}
Variable assign: {{ let newVariable = "value" }}
Multiline block: {{
let first = 20
let second = 30
first + second
}}
Conditional template: {{if( 1 == 2 )}} true {{ else }} false {{ endif }}
Conditional value: {{
if( 1 == 2 )
true
else
false
endif
}}
Conditional block: {{ if(value) }} Value is true {{ else }} Value is false {{ endif }}
Import: {{ import import "resourceName" }}
```