CFC function calls in pound signs


By David Fekke
January 17th, 2011

I try to write as little code as I can get away with. Because of this, I make functions calls like this in my cfoutput tags.

#myObj.getString()#

This is a lot easier to write than the following;

#myString#

The problem I ran into is I was putting quotes around my function call, and it was adding a space inbetween the quotes and the beginning of the string.

"#myString#"

" Actual String value"

What happens is if the function does not have output="no" it defaults to true. So just like in a regular cfm page, the white space is added to the function. If you set the output="no", no white space will appear. The result will look like this;

"Actual String value"

← Previous Page  Next Page →