Apache Velocity Part 4 – Comments in Template
There are three types of comments you can write in Velocity Template.
1. Single Line comments. (##)
2. Multi-Line comments. (#* … *#)
3. Java Doc-Style comments (#** …. *#)
Find below template for all three comments.
comments.vm
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
All about Velocity comments. ## This is single line comments. #* Multiple lines comments. This type of comments are not useful for documentation. *# #** Java doc style comments, It is useful for documentation. @author Dhiral Pandya @site Omtlab.com @version 7.7 *# |
Code Example :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
package com.omt.velocity.example; import java.io.StringWriter; import org.apache.velocity.Template; import org.apache.velocity.app.Velocity; public class CommentsVelocity { public CommentsVelocity() { // TODO Auto-generated constructor stub } public static void main(String[] args) { Velocity.init(); Template t = Velocity.getTemplate("comments.vm"); StringWriter writer = new StringWriter(); t.merge(null, writer); System.out.println(writer.toString()); } } |