Coding Custom Tags and Extensions

ColdFusion Extensions (CFXs) are an open XML-based framework for extending ColdFusion with new server components and connectivity to enterprise systems using COM, CORBA, C/C++, VBScript, JavaScript, or CFML.

Allaire's Developer Exchange

The Allaire Developer's Exchange, formerly the Tag Gallery, is a public collection of tools and extensions (written in CFML or with C++ using the ColdFusion API) that can be used in dynamic web applications.

Custom Tags should adhere to the coding styles you adopt for CFML and HTML, but there are some additional guidelines that you can follow to enhance their usability for both developers and end users.

Remember to comment your code and indent it -- both of these steps will help other developers use and understand your code more easily. Following a few basic style guidelines will also help others learn from the custom code you post.

Comment your code

If you're creating a ColdFusion Custom Tag that you intend to share with other developers, include the following information in a comment at the top of your code:

Custom tag names

The naming convention for custom CFML tags built using other CFML tags is CF_TagName. Unique, descriptive names make it easy for you and others to find the right tag. For example, the tag name CF_MyTag invokes the file MyTag.cfm.

To avoid ambiguity, the following naming convention should be observed for CFML tags:

Defining attributes

As the creator of the custom tag, you have the responsibility to specify a syntax for the tag's functionality. CFML custom tags support both required and optional attributes. Attributes are defined as name-value pairs. Custom tag attributes conform to CFML coding standards:

Protect variables in the CALLER scope

Custom tags should never arbitrarily create (or overwrite) hard-coded variables in the CALLER scope. They should allow the caller to specify the variable to be created.

Provide useful error handling

Custom tags should return error codes and allow the caller to determine whether or not to abort. They should not call CFABORT directly.