
216
DEVELOPING
COLDFUSION 9 APPLICATIONS
Building Blocks of ColdFusion Applications
Las
t
upda
te
d 8/5/2010
---custom tag ---<br>
<cfoutput>#attributes.a# #attributes.x# #attributes.y#
#attributes.foo#</cfoutput><br>
--- end custom tag ---
its output is the following statement:
---custom tag ---
blab -X- -Y- 16
--- end custom tag ---
One use for
attributeCollection
is to pass the entire Attributes scope of one custom tag to another. This technique
is useful when you have one custom tag that calls a second custom tag and you want to pass all attributes from the first
tag to the second.
For example, you call a custom tag with the following code:
<cf_first attr1="foo" attr2="bar">
To pass all the attributes of the first custom tag to the second, you include the following statement in first.cfm:
<cf_second attributeCollection="#attributes#">
Within the body of second.cfm, you reference the parameters passed to it as follows:
<cfoutput>#attributes.attr1#</cfoutput>
<cfoutput>#attributes.attr2#</cfoutput>
Managing custom tags
If you deploy custom tags in a multideveloper environment or distribute your tags publicly, you can use the advanced
security and template encoding capabilities of ColdFusion.
The ColdFusion security framework enables you to selectively restrict access to individual tags or to tag directories.
This restriction can be an important safeguard in team development. For more information, see “
Securing
Applications
” on page 339.
You can use the command line utility
cfcompile
to precompile your custom tag files into Java class files or byte code.
For more information, see Using the cfcompile utility in
Configuring and Administering ColdFusion
.
Executing custom tags
ColdFusion provides techniques for executing custom tags, including handling end tags and processing body text.
Accessing tag instance data
When a custom tag page executes, ColdFusion keeps data related to the tag instance in the
thisTag
structure. You can
access the
thisTag
structure from within your custom tag to control processing of the tag. The behavior is like that of
the
File
tag-specific variable (sometimes called the File scope).
ColdFusion generates the variables in the following table and writes them to the
thisTag
structure: