Mustache Template Action
Provided by: "Apache Software Foundation"
Support Level for this Kamelet is: "Stable"
Builds a new message body from a Mustache template, filling in values from the incoming message.
Use it to turn data into text for people or for another system, such as the text of an email or a chat message, or a small JSON or XML document, without writing code. To reshape JSON into other JSON, jsonata-action or jslt-action is often simpler.
Input: any body. The template sees the body as {{body}} and a header as {{headers.name}}.
Output: the body is the text the template produced. The headers are kept.
Good to know: the template is loaded from a file, the classpath or a URL given by the template option; it cannot come from the message. Headers that start with CamelMustache are removed from the message first, so they cannot change what the Kamelet does.
Configuration Options
The following table summarizes the configuration options available for the mustache-template-action Kamelet:
| Property | Name | Description | Type | Default | Example |
|---|---|---|---|---|---|
Template | Required Where to load the Mustache template from, not the Mustache template itself: | string | file:////template.mustache |
Dependencies
At runtime, the mustache-template-action Kamelet relies upon the presence of the following dependencies:
-
camel:mustache
-
camel:kamelet
Camel JBang usage
Prerequisites
-
You’ve installed JBang.
-
You have executed the following command:
jbang app install camel@apache/camel Supposing you have a file named route.yaml with this content:
- route:
from:
uri: "kamelet:timer-source"
parameters:
period: 10000
message: 'test'
steps:
- to:
uri: "kamelet:mustache-template-action"
parameters:
.
.
.
- to:
uri: "kamelet:log-sink" You can now run it directly through the following command
camel run route.yaml