Question
Rendering issues seen when nested quotes are used with the
IF variable. I know this seems like the most "newbie" of questions, but I cannot locate the desired info. What's the correct format for nested quotes when using
IF?
I've created a
IfRenderingIssue topic which incorporates nested quotes. I know that the usage of single and double quotes addresses the specific example. But what about more complex situations? The
VarIF help doesn't contain nested quotes information while
VarENCODE and
VarURLPARAM at least mention it (but the examples don't actually have any escaped quotes as far as I can tell).
The rendering of
IF doesn't seem to support escaped quotes or at least seems to have no impact. Is this something that should be supported? In addition, I'm wondering if this issu is related to
WebLeftBarIncludeIssue since similar HTML gets generated.
<img width=
Thanks,
dB...
Environment
--
DonBowden - 27 Jul 2007
Answer
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
TWiki evaluates TWiki variables inside-out and left-right, so if you say %IF{"%X%" then %X% will be evaluated before %IF. There is no way to change this evaluation order (there can't be, because of the way TWiki variables work

). So if %X expands to some text that contains quotes, it will break the parse of the "outer" %IF.
My usual approach to your specific problem is to use %NOP. Say, for example, you want search performed only if some condition evaluates to true. Write:
%%IF{"condition" then="SEARCH" else="NOP"}%{"search term"...}%
The %IF is evaluated first. If "condition" evaluates to true, the text expands to
%SEARCH{"search term"...}%
If it evaluates to false, then the text expands to
%NOP{"search term"...}%
which in turn expands to the empty string.
--
CrawfordCurrie - 01 Sep 2007