Skip to main content
August 21, 2008
Answered

How to evaluate a string that contains a cfif tag?

  • August 21, 2008
  • 1 reply
  • 543 views
Line 1 of the attached code has the output I want: "test that string".

Lines 2 and 3 aren’t getting the browser output I want: "test thisthat string".
Here is what lines 2 and 3 look like in the view source: "test <cfif 1 EQ 0>this<cfelse>that</cfif> string"

How to evaluate str so it prints "test that string"?

Thank you in advance.
This topic has been closed for replies.
Correct answer BKBK
How to evaluate str so it prints "test that string"?

Coldfusion wouldn't evaluate a tag that is part of a string. Use the functions iif() and de(). Your str should be something like

<cfset str = "test " & iif(1 EQ 0, de("this"), de("that")) & " string">

1 reply

BKBK
Community Expert
BKBKCommunity ExpertCorrect answer
Community Expert
August 21, 2008
How to evaluate str so it prints "test that string"?

Coldfusion wouldn't evaluate a tag that is part of a string. Use the functions iif() and de(). Your str should be something like

<cfset str = "test " & iif(1 EQ 0, de("this"), de("that")) & " string">