https://github.com/l-briand/tagtemplate
A named {{ tag }} template processor in kotlin.
https://github.com/l-briand/tagtemplate
kotlin kotlin-multiplatform kotlin-multiplatform-library template-engine-html template-engine-kotlin template-engines template-processor templates
Last synced: about 2 months ago
JSON representation
A named {{ tag }} template processor in kotlin.
- Host: GitHub
- URL: https://github.com/l-briand/tagtemplate
- Owner: L-Briand
- License: mit
- Created: 2022-04-21T20:19:46.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-02-06T11:26:53.000Z (almost 2 years ago)
- Last Synced: 2025-03-13T21:23:01.027Z (9 months ago)
- Topics: kotlin, kotlin-multiplatform, kotlin-multiplatform-library, template-engine-html, template-engine-kotlin, template-engines, template-processor, templates
- Language: Kotlin
- Homepage:
- Size: 226 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- License: LICENSE
Awesome Lists containing this project
README
## TT `{{ tag }} template`
A quick and easy to use library for those, who only want named {{ tag }} replacement in a string.
For a more advanced template processor, please look at my mustache templating
engine [L-Briand/KTM](https://github.com/L-Briand/KTM).
Default rendering:
```kotlin
val render = TT("Hello {{ name }}!", "name" to "John")
assert("Hello John!" == render)
val data = mapOf("name" to "John", "ag e" to 33)
assert("John, 33 y/o" == TT("{{ name }}, {{ ag e }} y/o", data))
data class User(val name: String)
assert("User(name=John)" == TT("{{ class }}", "class" to User("John")))
```
Custom delimiters:
```kotlin
val format = TT(start = "%%", stop = "%")
val render = format("Hello %% name %!", "name" to "John")
assert("Hello John!" == render)
```
Escape HTML:
```kotlin
val format = TT(HtmlEscape)
val render = format("{{ script }}", "script" to "alert('Hello')")
assert("<script>alert('Hello')</script>", render)
```
## Import from maven
### Multiplatform
```kotlin
repositories {
mavenCentral()
}
val commonMain by getting {
dependencies {
implementation("net.orandja.kt:TT:1.0.0")
}
}
```
### Jvm
```kotlin
repositories {
mavenCentral()
}
dependencies {
implementation("net.orandja.kt:TT:1.0.0")
}
```