Getting Started
Custom tags are just like regular CFML templates and can contain any combination of CFML, HTML, JavaScript, or other markup 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 ColdFusion applications:
- Code reuse
Custom tags give you a way to reuse frequently used code. You can create a single custom tag that can be called by any application residing on your server whenever the functionality it provides is needed. This allows you to develop your applications more quickly by reducing the amount of redundancy in your coding. It also improves development time in shared development environments where multiple developers have access to the same code base. Using custom tags, you can create a shared library of tags for handling various programming tasks that can be used by any developer on a given project.
- Abstraction
Using a custom tag allows you to abstract complex code and programming logic. To understand what we mean by ...
Get Programming ColdFusion MX, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.