User Guide

Table Of Contents
252 Chapter 11: Creating and Using Custom CFML Tags
<cfelse>
<!--- End tag processing --->
</B>
</cfif>
You then use this tag to convert the text to bold:
<cf_bold>This is bold text</cf_bold>
You can also use cfswitch to determine the execution mode of a custom tag:
<cfswitch expression=#thisTag.ExecutionMode#>
<cfcase value= 'start'>
<!--- Start tag processing --->
</cfcase>
<cfcase value='end'>
<!--- End tag processing --->
</cfcase>
</cfswitch>
Considerations when using end tags
How you code your custom tag to divide processing between the start tag and end tag is greatly
dependent on the function of the tag. However, you can use the following rules to help you make
your decisions:
Use the start tag to validate input attributes, set default values, and validate the presence of the
end tag if it is required by the custom tag.
Use the end tag to perform the actual processing of the tag, including any body text passed to
the tag between the start and end tags. For more information on body text, see “Processing
body text” on page 252.
Perform output in either the start or end tag; do not divide it between the two tags.
Processing body text
Body text is any text that you include between the start and end tags when you call a custom 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>
In this example, the two lines of code after the start tag are the body text.
You can access the body text within the custom tag using the
thisTag.GeneratedContent
variable. The variable contains all body text passed to the tag. You can modify this text during
processing of the tag. The contents of the
thisTag.GeneratedContent variable are returned to
the browser as part of the tag’s output.
The
thisTag.GeneratedContent variable is always empty during the processing of a start tag.
Any output generated during start tag processing is not considered part of the tag’s generated
content.