Template engines

A template engine is a tool that generates text output, such as emails, XML, JSon or code, by combining templates with dynamic data. In Camel, templates are primarily used to create layouts while dynamically using data from the current Message Exchange.

Below is a list of some of the template engines that are provided by Camel:

Template Artifact Description

components::chunk-component.adoc

camel-chunk

Transform messages using Chunk templating engine.

components::freemarker-component.adoc

camel-freemarker

Transform messages using FreeMarker templates.

components::jte-component.adoc

camel-jte

Transform messages using a Java based template engine (JTE).

components::mustache-component.adoc

camel-mustache

Transform messages using a Mustache template.

components::mvel-component.adoc

camel-mvel

Transform messages using an MVEL template.

components::string-template-component.adoc

camel-stringtemplate

Transform messages using StringTemplate engine.

components::thymeleaf-component.adoc

camel-thymeleaf

Transform messages using a Thymeleaf template.

components::velocity-component.adoc

camel-velocity

Transform messages using a Velocity template.

components::xslt-component.adoc

camel-xslt

Transforms XML payload using an XSLT template.

components::xslt-saxon-component.adoc

camel-xslt-saxon

Transform XML payloads using an XSLT template using Saxon.

To see a wider list try Camel CLI to execute: camel catalog component --filter=transform from the CLI.

Which template engine to choose

Velocity is a mature template engine with long-term support from Camel. It can be used for text generation, such as emails. Mustache can be used for similar purposes and is cross-platform.

For templates that require more conditional logic and XML or HTML output, Freemarker, MVEL, and Thymeleaf are good choices. JTE is known to be fast due to its compile-time template processing.

These template engines perform directly on the Exchange, if you want to template routes, look at Route Templates.