BackUp LevelNext

Writing Custom Tags

All CFML constructs can be used in custom tags and HTML can be included, too. You only need to be aware of a few requirements when creating custom tags.

Naming Custom Tags

Custom tags are identified by the CF_ prefix. Beyond that, you are free to use any naming convention that fits your development practice. 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

If you are concerned about possible name conflicts when invoking a custom tag or if the application must use a variable to dynamically call a custom tag at runtime, the CFMODULE element provides a solution. See Resolving file name conflicts.

Tag scope

Because custom tags are individual templates, there is no automatic exposure of variables and other data between a custom tag and the calling template. To pass data, you define attributes for the custom tag just as in standard CFML coding.

Data pertaining to the HTTP request or to current application is visible, however. This includes the variables in Form, URL, CGI, Cookies, Server, Application, Session, and Client.

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:


BackUp LevelNext

allaire

AllaireDoc@allaire.com
Copyright © 1998, Allaire Corporation. All rights reserved.