ColdFusion lets you turn a custom tag into a special kind of container that can enclose additional custom tags, which allows you to nest tags. Base tags are also know as ancestors or parent tags, while the tags that base tags call are known as sub tags, descendants, or child tags.
Terms to Describe the Relationship Between Nested Tags | ||
---|---|---|
Calling tag | Tag that is nested within the calling tag | Notes |
base tag | sub tag | A base tag is an ancestor that has been explicitly associated with a descendant with CFASSOCIATE. |
ancestor | descendant | An ancestor is any tag that contains other tags between its start and end tags. |
parent | child | "Parent" and "child" are synonyms for "ancestor" and "descendant." |
You can create multiple levels of nesting by closing a sub tag. 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:
No processing occurs in the base tag during this phase.
While the ability to create nested custom tags is a tremendous productivity gain, keeping track of complex nested tag hierarchies can become a chore. A simple mechanism, 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.