Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sdeleuze/kotlin-script-templating
Spring Boot + Kotlin type safe experimental template rendering
https://github.com/sdeleuze/kotlin-script-templating
Last synced: 3 months ago
JSON representation
Spring Boot + Kotlin type safe experimental template rendering
- Host: GitHub
- URL: https://github.com/sdeleuze/kotlin-script-templating
- Owner: sdeleuze
- Created: 2016-11-08T09:54:27.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-06-20T08:07:00.000Z (over 5 years ago)
- Last Synced: 2024-10-11T16:11:27.923Z (3 months ago)
- Language: Kotlin
- Homepage:
- Size: 120 KB
- Stars: 78
- Watchers: 6
- Forks: 9
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Spring Boot + Kotlin type safe template rendering with i18n and nested template support.
**This feature is considered experimental** since there is a lot of things to wire manually,
no cross-site scripting protection out of the box, the caching mechanism need to be improved,
etc.It requires Spring Framework 5.2 and Kotlin 1.3.40+.
Make sure to configure Spring Boot Gradle plugin as following to mke it working with Boot fat JAR.
`build.gradle.kts`
```kotlin
tasks.withType {
requiresUnpack("**/kotlin-compiler-*.jar")
}
```These templates look like:
```kotlin
import io.spring.demo.*"""
${include("header")}${i18n("title")}
- ${i18n("user")} ${it.firstname} ${it.lastname} " }}
${users.joinToLine{ "
${include("footer")}
"""
```
To enable variable resolution in `.kts` files in IDEA, go to menu preferences -> Build, Execution, Deployement -> Compiler -> Kotlin Compiler and set:
- Script templates class: `kotlin.script.templates.standard.ScriptTemplateWithBindings`
- Script templates classpath: `/path/to/kotlin-script-runtime.jar`
This may be configured automatically in future version of IDEA Kotlin plugin.
Feel free to send pull requests to improve it!