User Guide

Table Of Contents
166 Chapter 8: Creating ColdFusion Elements
Using custom CFML tags
Custom tags written in CFML behave like ColdFusion tags. They can do all of the following:
Take arg um ents .
Have tag bodies with beginning and ending tags.
Do specific processing when ColdFusion encounters the beginning tag.
Do processing that is different from the beginning tag processing when ColdFusion encounters
the ending tag.
Have any valid ColdFusion page content in their bodies, including both ColdFusion built-in
tags and custom tags (referred to as nested tags), or even JSP tags or JavaScript.
Be called recursively; that is, a custom tag can, if designed properly, call itself in the tag body.
Return values to the calling page in a common scope or the calling page’s Variables scope, but
custom tags do not return values directly, the way functions do.
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.
Calling custom CFML tags
Unlike built-in tags, you can invoke custom CFML tags in the following three ways:
Call a tag directly.
Call a tag using the cfmodule tag.
Use the 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>