ColdFusion Quickie: Tell if a file is being run as a custom tag

This post is more than 2 years old.

This just came in via Twitter so I thought I'd share the tip here. @orangeexception asked how you could tell if a file was being run as a custom tag. One quick and dirty way to do this is to just check for the existence of the ThisScope scope:

<cfif structKeyExists(variables, "ThisTag")> custom tag <cfelse> not a custom tag </cfif>

I've never bothered to do this with a custom tag, but I can see how it could help enforce folks using your tags in the right way.

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