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

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 developer advocate. He focuses on JavaScript, 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