• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

21. Creating Custom Tags > 21.3. Passing Data

Passing Data

Just like HTML and CFML tags, custom tags receive parameters via tag attributes. When you call a custom tag, you can pass parameters that automatically become available as variables within the custom tag. ColdFusion has a special variable scope called the attributes scope that refers to reference attributes that have been passed to a custom tag. For example, you can call a custom tag named cf_mytag like this:

<cf_mytag name="Pere Money"
          title="President">

Both name and title are tag attributes. Once the tag is called, these attributes and their associated values are available within the custom tag as attributes.Name and attributes.Title, respectively. Because the custom tag exists within its own scope, you must scope any variables with the attributes prefix in order to access them. Any ColdFusion datatype may be passed to a custom tag as an attribute. This allows you to create custom tags that can manipulate data from a variety of sources, including query objects, arrays, and structures, as well as such simple values as strings and numbers.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint