Kotlin 项目开发最佳实践: Kotlin + Spring Boot + kts(Kotlin Script) 全栈统一前后端

Spring Boot + Kotlin type safe template rendering with i18n and nested template support.

Requires Spring Framework 5.x and Kotlin 1.1+.

These templates look like:

import io.spring.demo.*

"""
${include("header")}
<h1>${i18n("title")}</h1>
<ul>
    ${users.joinToLine{ "<li>${i18n("user")} ${it.firstname} ${it.lastname}</li>" }}
</ul>
${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 will be configured automatically in future version of IDEA Kotlin plugin.

Feel free to send pull requests to improve it!

Kotlin 项目开发最佳实践: Kotlin + Spring Boot + kts(Kotlin Script) 全栈统一前后端...
image.png

相关文章:

  • 2021-11-06
  • 2021-08-01
  • 2021-05-01
  • 2021-04-09
  • 2021-12-05
  • 2022-01-22
  • 2021-06-06
  • 2021-09-02
猜你喜欢
  • 2021-04-15
  • 2021-04-12
  • 2021-05-24
  • 2021-04-18
  • 2021-05-30
  • 2021-05-26
  • 2021-08-18
相关资源
相似解决方案