User Guide

186 Chapter 10 Reusing Code
A custom tag page that performs processing in both modes can have the following
format:
<cfif thisTag.ExecutionMode is start>
<!--- Start tag processing --->
<cfelse>
<!--- End tag processing --->
</CFIF>
You can also use cfswitch:
<cfswitch expression=#thisTag.ExecutionMode#>
<cfcase value= start>
<!--- Start tag processing --->
</cfcase>
<cfcase value=end>
<!--- End tag processing --->
</cfcase>
</cfswitch>
Terminating tag execution
The cfexit tag terminates execution of a custom tag. The cfexit tags method
attribute specifies where execution continues.
cfexit 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:
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