Last updated
Ortus Solutions, Corp
Last updated
Comments are necessary and essential for any programming language. CFML is no different with helping you add code comments in both script and tag syntax.
You can use the <!---
and --->
Syntax to comment within a CFML template (.cfm
). This is very similar to HTML comments but adding an extra -
to demarcate it as a CFML comment.
If you are within a CFC or in a <cfscript>
block you can use an alternate style for comments. You can leverage //
for single line comments and the following for multi-line comments:
A multi-line block can affect the metadata of a component
or function
if the opening line contains 2 asterisks. Also, for readability, some people will start each line of the comment with an asterisk. The CF engines will parse out those starting asterisks and they will not appear in the component or the function metadata.
Tip: VSCode has some great plugins for generating this type of documentation on your CFCs. We recommend the following extensions:
Align - Helps align everything
AutoCloseTag - Helps close comment and well all tags
DocumentThis - Automatically generates detailed JSDoc, CFCDoc comments in TypeScript and JavaScript files.
In the CFML world, you can write comments in what we call CFCDoc comments. We leverage the library to generate documentation according to object metadata and comments. Please check out the section in the DocBox documentation to get a feel for how to document your code:
You can see some examples of advanced CFC documentation here:
You shall comment ALL your code!