This document contains important reference materials for working with properties in your templates.
| Type | Encoding | Example Value |
|---|---|---|
| String | string |
"Hello, world" |
| Boolean | boolean |
true |
| Int | int |
42 |
| Long | long |
9223372036854775807 |
| Float | float |
3.14 |
| Double | double |
3.141592653589793 |
| Enum | enum{value1, value2, ...} |
"value1" |
| List | list<E> |
["item1", "item2"] for list<string> |
| Object | object{K1: E1, K2: E2, ...} |
{"name": "John", "age": 30} |
| Nullables | E? |
null or a value of the specified type |
You can configure properties under pack.ksl.yaml. For example:
properties:
- key: serverModules
type: list<string>?
hidden: true
- key: configFormat
type: enum { HOCON, YAML, none }
default: HOCONThe back deserialized object can be found in PropertyTypes.kt.
This style of declaration MUST be used for handlebar templates, because there is no way to declare properties in the template itself.
When hidden is used, it's best to include a default. These properties will not be shown in the UI, and can only be populated from other packs included in the templated project.
You can declare properties in your Kotlin code using the _properties property. For example:
// Human-readable label
val variableName: String by _propertiesDeclaring this way will automatically include it in the resulting pack metadata, and it will appear in the UI for configuration.
Note, this does not allow for default values, but you can use nullable types.
You can assign values from other packs. For example:
propertyValues:
- key: io.ktor/server-core/serverModules
value: SerializationKt.configureSerializationIn this example, the value is parsed based on the declaration of the target pack. This can be useful for hidden properties.
Dynamic expressions can be applied for properties as well. This is useful for handlebars templates because inline expressions are not possible.
Here is an example:
propertyValues:
- key: isSinglePlatform
expression: _module.platforms.size == 1The expressions are parsed with the Kotlin compiler, though only a subset of Kotlin is supported in the script engine.