Aug 05

Call custom tags without cf_ or cfmodule

Posted by James Netherton | Tuesday 05 August 2008 1:59 PM | In ColdFusion

This may be common knowledge but I just stumbled upon it.....

The standard convention for invoking ColdFusion custom tags is to use:

<cf_mytag/>

or

<cfmodule template="mytag.cfm"/>

There's a way in which you are able to dispense with cf_ prefix and the <cfmodule> call. Browse to your ColdFusion WEB-INF\cftags directory. You should see some files relating to ColdFusion tags such as <cfdump> and <cfsavecontent>. You can add your own custom tag to this directory and invoke it from any CF template. For example:

Custom Tag - mytag.cfm

<cfdump var="#attributes#"/>

Calling Template

<cfmytag attribute1="test1" attribute2="test2"/>

Note that the cf_ or <cfmodule> prefix wasn't used. Instead the tag call looks like any normal ColdFusion tag invocation.

I doubt this has any real world usage but I thought it was worth blogging anyway.

 

1 Comment

[Post comment]


1

Posted by dfguy | Friday 29 August 2008 9:24 PM

or you can just use cfimport and give it a blank prefix like so:

<cfimport prefix = "" taglib = "/my_custom_tags_directory">

<cfmytag attribute1="test1" attribute2="test2"/>

Leave a comment








Captcha text