Custom tags written in CFML behave like ColdFusion tags. They can do all of the following:
Although a custom tag and a ColdFusion page that you include using the cfinclude
tag are both ColdFusion pages, they differ in how they are processed. When a page calls a custom tag, it hands processing off to the custom tag page and waits until the custom tag page completes. When the custom tag finishes, it returns processing (and possibly data) to the calling page; the calling page can then complete its processing. The following figure shows how this works. The arrows indicate the flow of ColdFusion processing the pages.
Unlike built-in tags, you can invoke custom CFML tags in the following three ways:
cfmodule
tag.cfimport
tag to import a custom tag library directory.
To call a CFML custom tag directly, precede the file name with cf_
, omit the .cfm extension, and put the name in angle brackets (<>). For example, use the following line to call the custom tag defined by the file mytag.cfm:
<cf_myTag>
If your tag takes a body, end it with the same tag name preceded with a forward slash (/), as follows:
</cf_myTag>
For information on using the cfmodule
and cfimport
tags to call custom CFML tags, see Chapter 10, "Creating and Using Custom CFML Tags".
ColdFusion custom tags let you abstract complex code and programming logic into simple units. These tags let you maintain a CFML-like design scheme for your code. You can easily distribute your custom tags and share tags with others. For example, the Macromedia ColdFusion Developer's Exchange includes a library of custom tags that perform a wide variety of often-complex jobs; see http://devex.macromedia.com/developer/gallery/index.cfm.
Consider using CFML custom tags in the following circumstances:
cfform
tag, which uses subtags for the individual form fields.If you can create either a UDF or a custom CFML tag for a purpose, first consider creating a UDF because invoking it requires less system overhead than using a custom tag.
For more information on custom CFML tags, see Chapter 10, "Creating and Using Custom CFML Tags".