Skip to content

Commit

Permalink
CAMEL-20029: camel-language - Missing examples in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
davsclaus committed Oct 23, 2023
1 parent 1d715c4 commit 6abec98
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions components/camel-language/src/main/docs/language-component.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,29 @@ include::partial$component-endpoint-headers.adoc[]
For example, you can use the xref:languages:simple-language.adoc[Simple] language to
Message Translator a message:

[source,java]
----
from("direct:hello")
.to("language:simple:Hello ${body}")
----

In case you want to convert the message body type you can do this as
well:
well (however it is better to use xref:eips:convertBodyTo-eip.adoc[Convert Body To]):

[source,java]
----
from("direct:toString")
.to("language:simple:${bodyAs(String.class)}")
----

You can also use the xref:languages:groovy-language.adoc[Groovy] language, such as this
example where the input message will by multiplied with 2:
example where the input message will be multiplied with 2:

[source,groovy]
----
from("direct:double")
.to("language:groovy:${body} * 2}")
----

You can also provide the script as a header as shown below. Here we use
xref:languages:xpath-language.adoc[XPath] language to extract the text from the `<foo>`
Expand Down

0 comments on commit 6abec98

Please sign in to comment.