# 6.5 Comments

The JFinal Template Engine supports both single-line and multi-line comments. Here's a code example:

### This is a single-line comment

#--
   This is the first line of a multi-line comment
   This is the second line of a multi-line comment
--#
1
2
3
4
5
6

As shown above, single-line comments use three # characters, while multi-line comments start with #-- and end with --#.

Unlike traditional template engines, single-line comments here use three characters primarily to reduce the likelihood of conflicts with the text content. Templates can contain highly diverse content, and using three characters significantly lowers the chances of conflicts.

Note for versions before JFinal 4.4: When a comment is placed on the same line as a directive, the output will remove the newline character following the comment. For example:

#("AAA") ### This is a comment
BBB
1
2

The output for the above template would be: "AAABBB". If you want the output to strictly adhere to the newlines in the template, place the comment on a separate line, like this:

### This is a comment, placed on its own line
#("AAA")
BBB
1
2
3

The output for this template will strictly follow the newlines, producing:

AAA
BBB
1
2

The same applies to multi-line comments; simply place them separately.

In all other cases, the output strictly follows the template's newlines. This issue has been resolved in JFinal version 4.4, so it's recommended to upgrade to version 4.4 or higher.

Last Updated: 9/22/2023, 4:50:57 AM