6. 注释

可以用注释加入描述性文本,他们并不在模板引擎中输出。注释可以有助于你的记忆或者想其他人解释你的VTL语句正在做什么。

  1. ## This is a single line comment.

单行注释以##开始,并在本行结束。如果需要加入多行注释,并不需要加入很多的单行注释。多行注释,以#开始并以#结束可以处理这种情况。

  1. This is text that is outside the multi-line comment.
  2. Online visitors can see it.
  3. #*
  4. Thus begins a multi-line comment. Online visitors won't
  5. see this text because the Velocity Templating Engine will
  6. ignore it.
  7. *#
  8. Here is text outside the multi-line comment; it is visible.

下面事一些例子说明单行注释和多行注释如何工作。

  1. This text is visible. ## This text is not.
  2. This text is visible.
  3. This text is visible. #* This text, as part of a multi-line comment,
  4. is not visible. This text is not visible; it is also part of the
  5. multi-line comment. This text still not visible. *# This text is outside
  6. the comment, so it is visible.
  7. ## This text is not visible.

还有第三种注释, VTL 注释块,可以用来存储诸如文档作者、版本信息等。

  1. #**
  2. This is a VTL comment block and
  3. may be used to store such information
  4. as the document author and versioning
  5. information:
  6. @author
  7. @version 5
  8. *#