Tuesday, August 30, 2011

Suppressing white space being added when using CFFUNCTION

I have run into this several times and I am sure others have as well.  I wrote a nice little CFFUNCTION to get rid of some redundant code.  Write the function, implement the function and now my output is broken because of some extra spaces showing up in the page now.  Duh, forgot to set output="false" on the CFFUNCTION tag, done this a bunch of times and will probably do it every once in a while still.  Maybe this post will cause me to stop doing it and commit it to permit long-term memory...

A bit more of an example...

<cffunction name="GetDuh" returntype="string">
<cfset returnvar = "duh" />
<cfreturn returnvar />
</cffunction>

This is a big ...#GetDuh()#... moment

returns: This is a big ... duh... moment

Change <cffunction name="GetDuh" returntype="string" output="false">

returns: This is a big ...duh... moment



No comments:

Post a Comment