470,862 Members | 1,701 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Share your developer knowledge by writing an article on Bytes.

Coldfusion Tips and Tricks

Careful use of # signs

The ## (pound) sign is very important in Coldfusion.

Expand|Select|Wrap|Line Numbers
  1. <cfoutput>#variablename#</cfoutput>
is OK.

However using ## inside cfset and cfif tags is not good coding.

The following would be considered bad coding:
Expand|Select|Wrap|Line Numbers
  1. <cfset var1=#variablename#>
  2. <cfif #variablename# eq "">
The ## sign are not necessary inside <cfif> and <cfset> tags because it takes more time to execute.

A good coding standard would be to avoid using pound signs around variables inside cfset and cfif tags:
Expand|Select|Wrap|Line Numbers
  1. <cfset var1=variablename>
  2. <cfif  variablename eq ""></cfif>
A tidbit of information but valuable nonetheless.

cfinclude and custom tags

All of us are familiar with cfinclude and custom tags, both tags are used to include a file. What is the difference between them?

The main difference between cfinclude and custom tag is that the include tag works in a copy-paste manner. The scope of variables used in the calling page is available in the included page. But custom tags are individual ColdFusion pages, variables and other data are not automatically shared between a custom tag and the calling page, so we have to pass it as arguments.
Mar 13 '08 #1
2 4685
16,027 Expert Mod 8TB
I've moved this to the Articles/howto section.

Thanks for posting this. The pound signs should only be used when necessary, so only surround the variables/functions that need them, not the whole text.
Mar 13 '08 #2
16,027 Expert Mod 8TB
Rather than having small bits of info, one article with a collection of tips is more useful.
Mar 31 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Howdy | last post: by
7 posts views Thread by acoder | last post: by
reply views Thread by travolta003 | last post: by
reply views Thread by travolta004 | last post: by
reply views Thread by smartfix | last post: by
8 posts views Thread by Frinavale | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.