TemplateProcessor

Utility object for injecting dynamic values into templates.

For example, given the following template and input context

Template:

Hello, {{user.name}}. Context:

{
"user": {
"name": "Bill"
}
}

The processed template would output

Hello, Bill.

In cases where the value may not be available in the context, a fallback string can be provided to be used instead. So given the following template and input context:

Template:

Hello, {{user.name || beloved user}}. Context:

{
"user": {
"age": 42
}
}

The processed template would output

Hello, beloved user.

Functions

Link copied to clipboard
fun process(template: String, context: DataObject): String

Processes the input template looking for all occurrences of double brace wrapped text: {{ }}