User Guide

Table Of Contents
Nesting custom tags 253
A custom tag can access and modify the generated content of any of its instances using the
thisTag.GeneratedContent variable. In this context, the term generated content means the
results of processing the body of a custom tag. This includes all text and HTML code in the body,
the results of evaluating ColdFusion variables, expressions, and functions, and the results
generated by descendant tags. Any changes to the value of this variable result in changes to the
generated content.
As an example, consider a tag that comments out the HTML generated by its descendants. Its
implementation could look like this:
<cfif thisTag.ExecutionMode is 'end'>
<cfset thisTag.GeneratedContent ='<!--#thisTag.GeneratedContent#-->'>
</cfif>
Terminating tag execution
Within a custom tag, you typically perform error checking and parameter validation. As part of
those checks, you can choose to abort the tag, using
cfabort, if a required attribute is not
specified or other severe error is detected.
The
cfexit tag also terminates execution of a custom tag. However, the cfexit tag is designed to
give you more flexibility when coding custom tags than
cfabort. The cfexit tag’s method
attribute specifies where execution continues. The
cfexit tag can specify that processing
continues from the first child of the tag or continues immediately after the end tag marker.
You can also use the
method attribute to specify that the tag body executes again. This enables
custom tags to act as high-level iterators, emulating
cfloop behavior.
The following table summarizes
cfexit behavior:
Nesting custom tags
A custom tag can call other custom tags from within it’s body text, thereby nesting tags.
ColdFusion uses nested tags such as
cfgraph and cfgraphdata, cfhttp and cfhttpparam, and
cftree and cftreeitem. The ability to nest tags allows you to provide similar functionality.
Method attribute value Location of cfexit call Behavior
ExitTag (default) Base page Acts like
cfabort
ExecutionMode=start Continue after end tag
ExecutionMode=end Continue after end tag
ExitTemplate Base page Acts like
cfabort
ExecutionMode=start Continue from first child in body
ExecutionMode=end Continue after end tag
Loop Base page Error
ExecutionMode=start Error
ExecutionMode=end Continue from first child in body