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

Chunk

camel-chunk

Transform messages using Chunk templating engine.

Freemarker

camel-freemarker

Transform messages using FreeMarker templates.

JTE

camel-jte

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

Mustache

camel-mustache

Transform messages using a Mustache template.

MVEL

camel-mvel

Transform messages using an MVEL template.

String Template

camel-stringtemplate

Transform messages using StringTemplate engine.

Thymeleaf

camel-thymeleaf

Transform messages using a Thymeleaf template.

Velocity

camel-velocity

Transform messages using a Velocity template.

XSLT

camel-xslt

Transforms XML payload using an XSLT template.

XSLT Saxon

camel-xslt-saxon

Transform XML payloads using an XSLT template using Saxon.

To see a wider list try Camel JBang 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.