Thursday, November 1, 2007

When to use # marks in CF code and when not

I was getting really confused for a while. Per page 179 in Ben Forta's web app construction kit book:

The following is the same functionally:
<cfset fullname="#FirstName# #LastName#">
<cfset fullname=FirstName & " " & LastName>

But his rule is: only use number signs when referring to variables and functions WITHIN A BLOCK OF TEXT.

I wish some of the sample code was more clear on this (like that generated by DW wizard).

Had to use this link to figure out how to get the demo code to appear.

But turns out it's a little harder than that. Tags like cfinvokeargument expect strings for each of each named value pairs, so we require "#variable#" syntax if we are passing in a struct...oy...

No comments: