Comments

Like most programming languages, VTL includes constructs for inserting descriptive text comments into a template. Both single-line and multi-line (block) comments are supported.

A single-line comments starts with ## and only lasts until the end of the line. The following are examples of single-line comments:

This is not a comment.     ## This is a comment.
## This whole line is a comment.

Multi-line comments are indicated by a start comment indicator (#*) and end comment indicator (*#). For example:

This text is outside of the comment block. It will be processed by the
template engine.
#*
  This text is inside the comment block.
  Therefore it will be ignored by the template engine.
*#
Back outside the comment block. This text will be processed.

There is a third form of comment referred to in the Velocity documentation as a VTL comment. This is another form of block comment. The following example is taken from the Velocity User's Guide:

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

It is unclear to this author the difference between multi-line comments and a VTL comment block.

Special Comment: Template Label

The Templates plugin also supports a special instance of the single-line comment to allow templates to be labelled. To label a template, add a single-line comment as the first line of the template file, using the following format:

## template = template_name

where template_name is the desired label.

For example, adding this comment as the first line of a template file:

## template = Java class

would indicate that the template file is to be labelled "Java class".

This label is used in place of the file name in the following locations:

  • dynamic menus under Plugins>Templates

  • dockable templates dialog

  • Templates accelerator option pane under Utilities>Global Options

PLEASE NOTE: the "##template =" statement replaces the "#ctpragma label" and "#ctpragma name" statements used by the Templates plugin until version 2.0.2.