Broken CFC outline in ColdFusion Builder? Check your HTML

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.

<cfcomponent>

&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&gt;

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

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

</cfcomponent> </code>

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 developer advocate for Extend by Auth0. He focuses on serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support.

Lafayette, LA https://www.raymondcamden.com

Comments