O'Reilly logo

Programming ColdFusion by Rob Brooks-Bilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 19. Creating Custom Tags

One of the most powerful features of ColdFusion is the ability to extend the core capabilities of the platform through components known as custom tags. Custom tags allow you to encapsulate code in a neat wrapper that can then be invoked from within any CFML template. Those familiar with other programming languages can think of custom tags as similar to subroutines or procedures.

There are two varieties of custom tags: custom CFML tags (referred to as custom tags) and CFX tags. Because developing CFX tags requires C++, Java, or Delphi experience, this chapter focuses on the development and use of custom tags, since they are written in CFML. A brief section at the end of the chapter discusses installing and calling CFX tags.

Getting Started

Custom tags are just like regular CFML templates and can contain any combination of CFML, HTML, and JavaScript code. What makes them different is how they are called and how they interact with the template that calls them. Custom tags allow you to pass attributes to them (just like other CFML and HTML tags), perform some sort of processing based on the attributes passed in, and can return data in the form of variables that can be used by the calling template in any number of ways. Let’s first look at the benefits of custom tags.

Why Custom Tags?

Right now, you are probably wondering about the specific types of situations that might warrant the use of custom tags. Here are four reasons to use custom tags in your ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required