Skip to content

keiSunagawa/tpas

Repository files navigation

What is tpas?

tpasはsbt project上で動かせるテンプレートエンジンwrapperと
生成ルール記述DSLを提供するsbt pluginです

Get Started

add settings and template in your sbt project.

  • project/build.properties
sbt.version=1.3.6
  • project/plugins.sbt
resolvers += "tpas repo" at "https://keisunagawa.github.io/tpas/repo/"
addSbtPlugin("me.kerfume" % "tpas" % "0.2.0")
  • templates/Hello.tpl.scala (or your scala code template.)
class {{ ctx.name }} {
  def hello(): Unit = println("hello, {{ message }}.")
}
  • build.sbt, add gen template dsl
enablePlugins(me.kerfume.tpas.Tpas)

import me.kerfume.tpas.dsl._
defTpasTask("genHello").setParser { arg =>
val json =
  s"""{
      |  "message": "${arg}"
      |}""".stripMargin
  minimum(
    dest = "tpas_example.hello.Hello",
    template = "Hello.tpl.scala",
    valuesJson = json
  )
}.build

run define your template gen task

$ sbt "genHello world"
$ cat src/main/scala/tpas_example/hello/Hello.scala
package tpas_example.hello

class Hello {
  def hello(): Unit = println("hello, .")
}

other example see example

Detail

see wiki

About

scala code template assets manage on sbt plugin

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages