Using CF Tags in CFSCRIPT

One question I see asked often is if you can use CFML tags in CFSCRIPT blocks. The technical answer is no. However, if you have CFMX, you can write wrapper UDFs for those tags and then call them from cfscript. This allows you to do stuff like:

<cfscript>
if(foo) location(newURL);
else {
    mail(toAddress,fromAddress,subject,body);
}

For a set of example UDFs in this area, see the CFMLLib at CFLib.

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