Page 1 of 1

nest quote matching between { }

Posted: 19 May 2016 21:31
by Bushmills
Example:

foo = "{variable} is {if (condition) "granted" else "denied"}";

doesn't pass editor syntax check. Replacing quotes within { } against ticks (single quotes, ') helps, but I believe that syntax check should be smart enough to recognize the new context of double quotes between curly brackets.

Re: nest quote matching between { }

Posted: 21 May 2016 12:46
by Martin
Doublequotes within a string need to be escaped with a backslash, otherwise the string is terminated when the second doublequote is encountered.
Following line should work:
foo = "{variable} is {if (condition) \"granted\" else \"denied\"}";

Re: nest quote matching between { }

Posted: 21 May 2016 12:57
by Bushmills
"...otherwise the string is terminated when the second doublequote.." - yes, that's why I'm asking for this: the curly braces { } are not becoming part of the string, instead they create a new interpretation context. Therefore it should make sense that double quotes are paired within that new context too. Else, for consistency reasons, one should ask to escape nested curly braces too, lest the closing brace of the inner pair of braces terminates the outer braces context ...