Skip to page content or Skip to Accesskey List.

Work

Main Page Content

Cf Has Smart Comment Tags

Rated 3.61 (Ratings: 4)

Want more?

  • More articles in Code
 
Picture of r937

rudy limeback

Member info

User since: 14 Dec 1998

Articles written: 12

ColdFusion's comment tags can be nested.

This isn't documented in Allaire's CFDOCS,

in fact the only reference to CF comments

I could find is in

Chapter 4 Quick Start to ColdFusion - Creating Simple Dynamic Pages --

Note the use of the comment convention used in ColdFusion pages:

<!--- and --->. ColdFusion comments use a form similar to HTML

comments, but with an additional hyphen.

Well, this isn't exactly true unless

you interpret the word "similar" loosely.

Unlike CF comments,

HTML comments are cannot be nested.

For example, consider the following block of HTML

this is uncommented HTML

<!-- this is a comment -->

this again is uncommented

<!-- this is another comment -->

finally, this too is uncommented

If you have ever tried to comment out an entire

block of HTML like the above, you will

have quickly discovered that

you can not just slap opening

and closing comment tags around the

block --

<!-- open my comment

this is uncommented

<!-- this is a comment -->

this again is uncommented

<!-- this is another comment -->

finally, this too is uncommented

close my comment -->

The above will not

give the intended results, because the opening <!-- tag

will be matched by the first --> tag encountered, despite the

fact that there was a nested <!-- between them.

Cold Fusion comments, however, can be nested, and the

following will

give the intended results --

<!--- open my CF comment

this is uncommented

<!--- this is a CF comment --->

this again is uncommented

<!--- this is another CF comment --->

finally, this too is uncommented

close my CF comment --->

Everything between the

<!---

and

--->

is one large CF comment, and none of it will be passed to

the web server by Cold Fusion.

Neat, eh?

My involvement with evolt.org goes back to 1998, as one of the original founders. I'm an SQL consultant who dabbled in web development for several years, in the "golden age" between HTML 2 and XHTML 1.1. My web sites are r937.com and rudy.ca. I live in Toronto, Canada, and you are all cordially invited to come and visit and play a round of frisbee golf with me.

The access keys for this page are: ALT (Control on a Mac) plus:

evolt.org Evolt.org is an all-volunteer resource for web developers made up of a discussion list, a browser archive, and member-submitted articles. This article is the property of its author, please do not redistribute or use elsewhere without checking with the author.