User Guide
Using Custom Tags 177
Passing custom tag attributes via CFML structures
You can use the reserved attribute attributecollection to pass attributes to
custom tags.
Attributecollection must reference a structure that contains the
attribute names as the keys and the attribute values as the values. You can freely mix
attributecollection with other attributes when you call a custom tag.
The key-value pairs in the structure specified by
attributecollection get copied
into the called page Attributes scope. This has the same effect as specifying the
attributecollection entries as individual attributes when you call the custom tag.
The custom tag page refers to the attributes passed using
attributecollection the
same way as it does other attributes; for example as Attributes.CustomerName or
Attributes.Department_number.
If the called custom tag uses a
cfassociate tag to save its attributes in the base tag,
the attributes passed via structure are saved as independent attribute values, with no
indication that they were aggregated into a structure by the custom tag’s caller.
Custom tag processing reserves
attributecollection to refer to the structure
holding a collection of custom tag attributes. If
attributecollection does not refer
to such a collection, the ColdFusion generates a Template exception.
The following example uses an attributecollection to pass two of four attributes:
<cfset zort=StructNew()>
<cfset zort.x = "-X-">
<cfset zort.y = "-Y-">
<cf_testtwo a="blab" attributecollection=#zort# foo="16">
If testtwo.cfm contains this CFML:
---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- 12 16
--- end custom tag ---