Apache Velocity first released in April 2001, is a
template language to reference objects defined in Java code. It aims to ensure clean separation between the presentation tier and business tiers in a Web application (the model–view–controller
Some common types of applications that use Velocity are:
AWS API Gateway body mapping template.Web applications: Web developers render HTML page structures. The content is populated with dynamic information. The page is processed with VelocityViewServlet or any of a number of frameworks that support Velocity.
XML transformation: Velocity provides an Ant task, called Anakia, which reads an XML file and makes it available to a Velocity template. A common application is to convert software documentation stored in a generic "xdoc" format into a styled HTML document.
AWS API Gateway uses Apache Velocity engine for body mapping templates - JSON is output.
Code examples
The following
template
:
## Velocity Hello World<html><body>#set($foo="Velocity")## followed by
Hello $foo World!
</body></html>
processed by Velocity produces the following HTML:
The syntax and overall concept of the Apache Velocity templates is similar to the syntax of the older WebMacro template engine, which is now also an open source project. [citation needed]