// Do not edit directly!
// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
[id="extensions-qute"]
= Qute
:page-aliases: extensions/qute.adoc
:linkattrs:
:cq-artifact-id: camel-quarkus-qute
:cq-native-supported: true
:cq-status: Stable
:cq-status-deprecation: Stable
:cq-description: Transform messages using Quarkus Qute templating engine
:cq-deprecated: false
:cq-jvm-since: 1.0.0
:cq-native-since: 1.0.0

ifeval::[{doc-show-badges} == true]
[.badges]
[.badge-key]##JVM since##[.badge-supported]##1.0.0## [.badge-key]##Native since##[.badge-supported]##1.0.0##
endif::[]

Transform messages using Quarkus Qute templating engine

[id="extensions-qute-maven-coordinates"]
== Maven coordinates

https://{link-quarkus-code-generator}/?extension-search=camel-quarkus-qute[Create a new project with this extension on {link-quarkus-code-generator}, window="_blank"]

Or add the coordinates to your existing project:

[source,xml]
----
<dependency>
    <groupId>org.apache.camel.quarkus</groupId>
    <artifactId>camel-quarkus-qute</artifactId>
</dependency>
----
ifeval::[{doc-show-user-guide-link} == true]
Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
endif::[]

[id="extensions-qute-usage"]
== Usage
include::partial$component-configure-options.adoc[]
include::partial$component-endpoint-options.adoc[]
include::partial$component-endpoint-headers.adoc[]

[id="extensions-qute-usage-qute-template-data"]
=== Qute template data

Camel will populate the Qute `TemplateInstance` data model with exchange information. The following options are available within Qute templates as variables:

[width="100%",cols="50%,50%",options="header",]
|=======================================================================
|key |value

|`exchange` |The `Exchange` itself.

|`exchange.properties` |The `Exchange` properties.

|`variables` |The exchange variables

|`headers` |The headers of the In message.

|`camelContext` |The Camel Context.

|`request` |The In message.

|`body` |The In message body.

|`response` |The Out message (only for InOut message exchange pattern).
|=======================================================================

You can configure your own template data with the message header `CamelQuteTemplateData` like this.

[source,java]
--------------------------------------------------------------------
Map<String, Object> variableMap = new HashMap<String, Object>();
variableMap.put("headers", headersMap);
variableMap.put("body", "Monday");
variableMap.put("exchange", exchange);
exchange.getMessage().setHeader("CamelQuteTemplateData", variableMap);
--------------------------------------------------------------------

[id="extensions-qute-usage-dynamic-templates"]
=== Dynamic templates

Camel provides headers `CamelQuteResourceUri`, `CamelQuteTemplate` and `CamelQuteTemplateInstance` which can be used to define a different resource
location for a template, or provide the template instance itself. If any of these headers is set, then Camel uses this over
the endpoint configured resource. This allows you to provide a dynamic template at runtime.

[id="extensions-qute-usage-examples"]
=== Examples

Processing an exchange with a Qute template read from the classpath.

[source,java]
-------------------------------------------
from("direct:start")
    .to("qute:org/acme/myTemplate.txt");
-------------------------------------------

Processing an exchange with a Qute template read from a file-based resource.

[source,java]
-------------------------------------------
from("direct:start")
    .to("qute:file://path/to/myTemplate.txt");
-------------------------------------------

Dynamic template path URI.

[source,java]
---------------------------------------------------------------------------------------------
from("direct:start")
    .setHeader(QuteConstants.QUTE_RESOURCE_URI).constant("org/acme/template.txt")
    .to("qute:dynamic?allowTemplateFromHeader=true");
---------------------------------------------------------------------------------------------

Dynamic template content.

[source,java]
---------------------------------------------------------------------------------------------
from("direct:start")
    .setHeader(QuteConstants.QUTE_TEMPLATE).constant("<hello>{headers.greeting}</hello>")
    .to("qute:dynamic?allowTemplateFromHeader=true");
---------------------------------------------------------------------------------------------

Dynamic template content with specified content type.

[source,java]
---------------------------------------------------------------------------------------------
from("direct:start")
    .setHeader(QuteConstants.QUTE_TEMPLATE).constant("<hello>{headers.greeting}</hello>")
    .setHeader(QuteConstants.QUTE_TEMPLATE_CONTENT_TYPE).constant("text/html")
    .to("qute:dynamic?allowTemplateFromHeader=true");
---------------------------------------------------------------------------------------------

Dynamic template instance.

[source,java]
---------------------------------------------------------------------------------------------
from("direct:start")
    .setHeader(QuteConstants.QUTE_TEMPLATE_INSTANCE).constant(myTemplateInstance)
    .to("qute:dynamic?allowTemplateFromHeader=true");
---------------------------------------------------------------------------------------------

Qute template example.

----------------------------------------------
Dear {headers.lastName}, {headers.firstName}

Thanks for the order of {headers.item}.

Regards Camel Riders Bookstore
{body}
----------------------------------------------

[id="extensions-qute-usage-quarkus-qute-documentation"]
=== Quarkus Qute documentation

For more information about Qute, please refer to the https://quarkus.io/guides/qute[Quarkus Qute] documentation.


[id="extensions-qute-camel-quarkus-limitations"]
== Camel Quarkus limitations

[id="extensions-qute-limitations-allowcontextmapall-option-in-native-mode"]
== allowContextMapAll option in native mode

The `allowContextMapAll` option is not supported in native mode as it requires reflective access to security sensitive camel core classes such as
`CamelContext` & `Exchange`. This is considered a security risk and thus access to the feature is not provided by default.



[id="extensions-qute-additional-camel-quarkus-configuration"]
== Additional Camel Quarkus configuration

By default, all files located in the src/main/resources/templates directory and its subdirectories
are registered as templates. Templates are validated during startup and watched for changes in the
development mode.

