3.3 Comments

Comments allows descriptive text to be included in a template that is not placed into the output of the template engine. Comments are a useful way of reminding yourself and explaining to others what your VTL statements are doing, or any other purpose you find useful.

Like the Java programming language, Velocity has single-line and block comments.

A single line comment begins with ## and finishes at the end of the line. This is an example of a single line comment in VTL:

## This is a single line comment.

This is visible in the output ## This is a comment.

If you are going to write a few lines of commentary, there is no need to have numerous single line comments. Multi-line comments, which begin with #* and end with *#, are available to handle this scenario:

This is text that is outside the multi-line comment.
Online visitors can see it.

#*
  Thus begins a multi-line comment. Online visitors will not
  see this text because the Velocity Templating Engine will
  ignore it.
*#

Here is text outside the multi-line comment; it is visible.

Multiline comments can start and end in arbitrary columns of the template.

There is a third type of comment, the VTL comment block, which may be used to store such information as the document author and versioning information. It is similar to the Javadoc comment block in the Java programming language:

#**
This is a VTL comment block and
may be used to store such information
as the document author and versioning
information:
@author
@version 5
*#