Comments allows descriptive text to be included 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. Below is an example of a comment in VTL.
## This is a single line comment.
A single line comment begins with ##
and finishes at the end of the line. If
you're going to write a few lines of commentary, there's 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. #* This begins a multi-line comment. Online visitors won't see this
text because the Velocity Templating Engine will ignore it. *#
Here is text outside the multi-line comment; it is visible.
Here are a few examples to clarify how single line and multi-line comments work:
This text is visible. ## This text is not. This text is visible. This text is visible. #* This text, as part of a multi-line
comment, is not visible. This text is not visible; it is also
part of the multi-line comment. This text still not
visible. *# This text is outside the comment, so it is visible. ## This text is not visible.
There is a third type of comment, the VTL comment block, which may be used to store any sort of extra information you want to track in the template (such as Javadoc-style author and versioning information):
#**
This is a VTL comment block and it may be used to store such information
as the document author and versioning information:
@author
@version 5
*#