// Do not edit directly!
// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
[id="extensions-freemarker"]
= Freemarker
:linkattrs:
:cq-artifact-id: camel-quarkus-freemarker
:cq-native-supported: true
:cq-status: Stable
:cq-status-deprecation: Stable
:cq-description: Transform messages using FreeMarker templates.
:cq-deprecated: false
:cq-jvm-since: 1.1.0
:cq-native-since: 1.8.0

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

Transform messages using FreeMarker templates.

[id="extensions-freemarker-whats-inside"]
== What's inside

* xref:{cq-camel-components}::freemarker-component.adoc[Freemarker component], URI syntax: `freemarker:resourceUri`

Please refer to the above link for usage and configuration details.

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

https://{link-quarkus-code-generator}/?extension-search=camel-quarkus-freemarker[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-freemarker</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-freemarker-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-freemarker-additional-camel-quarkus-configuration"]
== Additional Camel Quarkus configuration

[id="extensions-freemarker-configuration-quarkiverse-freemarker-and-its-configuration"]
== Quarkiverse Freemarker and its configuration

Camel Quarkus Freemarker uses dev/index.html[Quarkiverse Freemarker] under the hood.
This means in particular, that the `freemarker.template.Configuration` bean produced by Quarkiverse Freemarker
is used by Camel Quarkus.
The bean can be configured via `quarkus.freemarker.*` properties
- check https://quarkiverse.github.io/quarkiverse-docs/quarkus-freemarker/dev/index.html[Freemarker Configuration Reference]
for more details.

If you wish to use your custom `Configuration` bean instead of the default provided by Quarkiverse Freemarker,
you can let CDI to do the required wiring:

[source,java]
----
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Produces;
import jakarta.inject.Named;
import freemarker.template.Configuration;
import io.quarkus.arc.Unremovable;
import org.apache.camel.builder.RouteBuilder;

@ApplicationScoped
public class MyRoutes extends RouteBuilder {

    @Produces
    @ApplicationScoped
    @Unremovable
    @Named("myFreemarkerConfig")
    Configuration produceFreemarkerConfig() {
        Configuration result = new Configuration();
        ...
        return result;
    }

    @Override
    public void configure() {
        from("direct:example")
            .to("freemarker:templates/email.ftl?configuration=myFreemarkerConfig")

    }
}
----

