Apache Velocity


Apache Velocity is a Java-based template engine that provides 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.
Velocity is an open source software project hosted by the Apache Software Foundation. It is released under the Apache License. Jon Scott Stevens derived the name from the AltiVec Velocity Engine in the PowerPC G4 chip.

Uses

Some common types of applications that use Velocity are:
The following template:

  1. # Velocity Hello World


#set
## followed by
Hello $foo World!



processed by Velocity produces the following HTML:



Hello Velocity World!



Another example using conditions:
  1. if
**Go North**
  1. elseif
**Go East**
  1. elseif
**Go South**
  1. else
**Go West**
  1. end
For AWS API Gateway body mapping template, for DynamoDB HTTP:
Another example with ; without condition will fail because of invalid resulting JSON:
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.