Creating custom tags

Custom tags let you extend CFML by adding your own tags to the ones supplied with ColdFusion. After you define a custom tag, you can use it on a ColdFusion page just as you would any of the standard CFML tags, such as cfquery and cfoutput.

You use custom tags to encapsulate your application logic so that it can be referenced from any ColdFusion page. Custom tags allow for rapid application development and code reuse while offering off-the-shelf solutions for many programming chores.

For example, you might create a custom tag, named cf_happybirthday, to generate a birthday message. You could then use that tag in a ColdFusion page, as follows:

<cf_happybirthday name="Ted Cantor" birthDate="December 5, 1987">

When ColdFusion processes the page containing this tag, it could output the message:

December 5, 1987 is Ted Cantor's Birthday.
Please wish him well.

A custom tag can also have a body and end tag, for example:

<cf_happybirthdayMessge name="Ellen Smith" birthDate="June 8, 1993">
   <P> Happy Birthday Ellen!</P>
   <P> May you have many more!</P>
</cf_happybirthdayMessge>

This tag could output the message:

June 8, 1993 is Ellen Smith's Birthday.
Happy Birthday Ellen!
May you have many more!

For more information about using end tags, see Handling end tags.

This section describes the following topics:


View comments in LiveDocs