Stand with Ukraine 🇺🇦
Products
Services
Blog
About Us

Velocity

Apache Velocity is a server-side templating language used in Confluence to render page content. It enables integration of Java objects within standard HTML, making it a powerful tool for user macros.

Key Characteristics

  • Designed to dynamically generate content by combining static text with variable references, directives, and expressions.

  • Highly flexible, allowing developers to integrate it with various data sources and Java objects. It supports custom tools, macros, and user-defined directives.

278f6acc-d93a-4a67-82be-454fd973ebda.webp

Syntax Basics

Below are some common Velocity syntax elements used in Confluence:

Element

Syntax

Example

Variable reference

$variableName

$foo

Variable assignment

#set ($var = value)

#set ($message = "Hello")

Conditional statements

#if ... #else ... #end

#if ($message == "Hello")
Message is Hello
#end

Loops

#foreach ($item in $collection) ... #end

#break

#stop

#foreach ($user in $users)
$user <br> 
#end
#foreach ($item in $items)
#if ($item == "stop")
#break
##if ($error)
rror)
#stop
#end

Quiet notation

$!variable

#set($name = "Kevin")

Hello, $name! ## Output: Hello, Kevin!
Hello, $unknown! ## Output: Hello, $unknown!
Hello, $!unknown! ## Output: Hello, ! (avoids rendering the output literally)

To learn more about Velocity, please see the Velocity user guide.

Handling Null Values

{"timestamp":1792799680505,"msg":"A unknown Exception Occurred","errorMsg":"The provided AtlassianHostUser did not specify a user to act as.","code":"500"}