A custom tag can call other custom tags, thereby nesting tags. ColdFusion uses nested tags such as cfgraph
and cfgraphdata
, cfhttp
and cfhttppam
, and cftree
and cftreeitem
. The ability to nest tags allows you to provide similar functionality.
The calling tag is known as an ancestor, parent, or base tag, while the tags that ancestor tags call are known as descendant, child, or sub tags. Together, the ancestor and all descendent tags are called collaborating tags.
The following table lists the terms that describe the relationships between nested tags:
In order to nest tags, the parent tag must have a closing tag.
You can create multiple levels of nested tags. In this case, the sub tag becomes the base tag for its own sub tags. Any tag with an end tag present can be an ancestor to another tag.
Nested custom tags operate through three modes of processing, which are exposed to the base tags through the variable thisTag.ExecutionMode
:
While the ability to create nested custom tags is a tremendous productivity gain, keeping track of complex nested tag hierarchies can become a chore. The cfassociate
tag lets the parent know what the children are up to. By adding this tag to a sub tag, you enable communication of its attributes to the base tag.