Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

#...# expression leaves superflous space behind for the first #

Explorer ,
Jan 21, 2011 Jan 21, 2011

hi there

I run CF 9.01 and have a nasty white space problem:

I populate a form field like this:

---

... value="#application.utils.FormatTS(now())#" ...

---

This leaves behind in the source code generated the followng:

----

value=" 2011-01-22 03:34:03"

---

The empty space later generates a problem. I have observed this bug throughout all versions of CF. One can avoid this in all situation where one can concatenate strings like in "some test" & application.utils.FormatTS() ... this will not geneate the empty space.

CF's IsDate () returns NO if the space is there ...LSIsDate () returns YES ... inconsistent behavior IMHO.

BTW: The function FormatTS () does NOT generate the leading space. It is the way how CF generates the code

BTW: I know that I can get rid of the space with trim() ... however, it's a mess to be forced to do so in ALL processing of such constructs ...

Any remedy known for this? Or any reason WHY CF does it like this? How can I seduce it not to generate suc code?

Thanks

Martin

407
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Jan 21, 2011 Jan 21, 2011

BTW: The function FormatTS () does NOT generate the leading

space. It is the way how CF generates the code

Are you positive? Because that certainly is the most likely cause. Check the cffunction and make sure you have set output="false".

Translate
Valorous Hero ,
Jan 21, 2011 Jan 21, 2011

BTW: The function FormatTS () does NOT generate the leading

space. It is the way how CF generates the code

Are you positive? Because that certainly is the most likely cause. Check the cffunction and make sure you have set output="false".

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 21, 2011 Jan 21, 2011

Yes, I am sure

This is the cfc wth the method

---

<cfcomponent output="false">


   <cffunction name="FormatTS" access="public" returntype="string" hint="Returns a timestamp formatted as yyyy-mm-dd hh:mm:ss">

      <cfargument name="Timestamp"           type="any"    required="yes">

      <cfargument name="Date_Time_Separator" type="string" required="no" default=" ">

      <cfreturn (arguments.Timestamp gt "" ? DateFormat (arguments.Timestamp, "yyyy-mm-dd") & arguments.Date_Time_Separator & TimeFormat (arguments.Timestamp, "HH:mm:ss") : "")>

   </cffunction>

---

Howerver, I see that I can also set output="false" in the method. I was not aware that this MUST be done ... cause obviously, when doing so, the superfluos space does disappear .... so, your comment helped. Strange, I don't understand the difference right now .. anyway.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jan 21, 2011 Jan 21, 2011
LATEST

You need to specify output="false" on the function too.

(Update: I responded via email before I saw your edit.)

The documentation says it controls whether "the entire function body is processed as if it were in a cfoutput tag...". (and functions do not inherit the setting of the parent cfcomponent tag). I cannot say I always understand how certain code ends up creating the whitespace in the first place. But as it is easily fixed, I never spent that much time investigating.

Message was edited by: -==cfSearching==-

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources