Skip to content

Commit 8c9bb1b

Browse files
author
ntwigg
committed
Document the JTE plugin.
1 parent 25ebe5b commit 8c9bb1b

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
- [node](#node) - hassle-free `npm install` and `npm run blah`
44
- [static server](#static-server) - a simple static file server
5+
- [jte](#jte) - creates idiomatic Kotlin model classes for `jte` templates (strict nullability & idiomatic collections and generics)
56

67
## Node
78

@@ -30,3 +31,38 @@ tasks.register('serve', com.diffplug.webtools.serve.StaticServerTask) {
3031
port = 8080 // by default
3132
}
3233
```
34+
35+
### JTE
36+
37+
You have to apply `gg.jte.gradle` plugin yourself. We add a task called `jteModels` which creates a Kotlin model classes with strict nullability. Like so:
38+
39+
```jte
40+
// header.jte
41+
@param String title
42+
@param String createdAtAndBy
43+
@param Long idToImpersonateNullable
44+
@param String loginLinkNullable
45+
```
46+
47+
will turn into
48+
49+
```kotlin
50+
class header(
51+
val title: String,
52+
val createdAtAndBy: String,
53+
val idToImpersonateNullable: Long?,
54+
val loginLinkNullable: String?,
55+
) : common.JteModel {
56+
57+
override fun render(engine: TemplateEngine, output: TemplateOutput) {
58+
engine.render("pages/Admin/userShow/header.jte", mapOf(
59+
"title" to title,
60+
"createdAtAndBy" to createdAtAndBy,
61+
"idToImpersonateNullable" to idToImpersonateNullable,
62+
"loginLinkNullable" to loginLinkNullable,
63+
), output)
64+
}
65+
}
66+
```
67+
68+
We also translate Java collections and generics to their Kotlin equivalents. See `JteRenderer.convertJavaToKotlin` for details.

0 commit comments

Comments
 (0)