Broken CFC outline in ColdFusion Builder? Check your HTML

This post is more than 2 years old.

From time to time I'll encounter a CFC that is 'broken' in the outline. By broken I mean the method listing goes up to a certain point and just plain stops. I don't encounter this very often, but when I do, it's normally a case of needing to find some method after the mysterious stopping point. I brought this up with Adobe, and used a specific file as an example, and today Ramchandra (Adobe engineer) shared with me what the issue was - invalid HTML.

Let's look at an example of this. The following CFC closely resembles the one that originally had a broken outline.


&lt;cffunction name="badboy"&gt;
	&lt;cfset var str = ""&gt;
	&lt;cfsavecontent variable="str"&gt;&lt;tr&gt;&lt;/cfsavecontent&gt;
	&lt;cfreturn str&gt;

&lt;cffunction name="goodboy"&gt;
	&lt;cfreturn "&lt;tr&gt;"&gt;

&lt;cffunction name="placeholder1"&gt;
	&lt;cfreturn 1&gt;


Notice the very first method, badboy, returns a TR tag. This is perfectly valid CFML. You could imagine a real use for this - perhaps in a method called startTableRow. And yea - this would be way over enginered - but I've bet we've all seen code like that before. Check out what the outline does with it though:

As you can see, it stops at badboy and doesn't render anything past that. If we comment out badboy we get:

Now - in the code above - there is really no bug. In my original CFC shared with Adobe there definitely was. (This is in Galleon and will be fixed today.) I've made the argument that the code above should not break the outline. That being said though - if you have outline issues - check for something like this.

On a related note, I've noticed that CFBuilder will not correctly flag invalid HTML. Create a new HTML file in CFBuilder, write a B tag and don't close it, and you get no error or warning. Do the same in Aptana. I've asked about why this happens and if I find out I'll post back.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA

Archived Comments

Comment 1 by Mike posted on 11/29/2010 at 8:03 PM

In CFEclipse, nested CF comments will also prevent proper "outline mode" rendering.

Comment 2 by Raymond Camden posted on 11/29/2010 at 8:05 PM

Interesting. I tested that in CFB - commented out badboy, and INSIDE of the comment block added another comment. It did not break the outline.

Comment 3 by Ram Kulkarni posted on 11/29/2010 at 8:14 PM

Functions are still there in the outline view, but they are shown as children of <tr>, since it was not closed. Agree that this is not the correct hierarchy, but since CFB shows all CFML and HTLM tags in the outline, it would be difficult, if not impossible, to correctly display documents, that are not well formed, in the outline view. Quick outline will show all functions in this case.

Comment 4 by Raymond Camden posted on 11/29/2010 at 8:19 PM

Confirmed - when I open TR it is there.

While I would like the outline to handle my method above, in the _real_ example it was truly broken HTML. So hopefully this post will help others find broken HTML in their CFCs/CFMs. :)