davsclaus commented on a change in pull request #4561: URL: https://github.com/apache/camel/pull/4561#discussion_r530112288
########## File path: components/camel-datasonnet/src/main/docs/datasonnet-language.adoc ########## @@ -0,0 +1,193 @@ +[[datasonnet-language]] += DataSonnet Language +:docTitle: DataSonnet +:artifactId: camel-datasonnet +:description: To use DataSonnet scripts in Camel expressions or predicates. +:since: 3.7 +:supportLevel: Preview +include::{cq-version}@camel-quarkus:ROOT:partial$reference/languages/datasonnet.adoc[opts=optional] + +*Since Camel {since}* + +Camel supports https://datasonnet.com/[DataSonnet] transformations to allow an Expression or Predicate to be used in the Java DSL or xref:manual::xml-configuration.adoc[XML +Configuration]. + +To use a DataSonnet expression use the following Java code: +[source,java] +--------------------------------------- +... datasonnet("someDSExpression") ... +--------------------------------------- + +== Example + +Here is a simple example using a DataSonnet expression as a predicate in a Message Filter: + +[source,java] +------------------------------------------------------------------------------------------------ +// lets route if a line item is over $100 +from("queue:foo") + .filter(datasonnet("ds.arrays.firstWith(body.lineItems, function(item) item > 100) != null")) + .to("queue:bar") +------------------------------------------------------------------------------------------------ + +And the Spring DSL: + +[source,xml] +----------------------------------------------------------------------------- +<route> + <from uri="queue:foo"/> + <filter> + <datasonnet>ds.arrays.firstWith(body.lineItems, function(item) item > 100) != null</datasonnet> Review comment: Ah yeah there may be some mistakes in other parts of the docs. However you need to escape this in XML, but then they are harder to read, > vs > - but we can leave this as-is. How is it going with all the other review comments? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org