nest quote matching between { }

Post your feature requets for new triggers, conditions, actions and other improvements.

Moderator: Martin

Locked
User avatar
Bushmills
Posts: 286
Joined: 23 Sep 2014 21:56

nest quote matching between { }

Post by Bushmills » 19 May 2016 21:31

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.

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: nest quote matching between { }

Post by Martin » 21 May 2016 12:46

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\"}";

User avatar
Bushmills
Posts: 286
Joined: 23 Sep 2014 21:56

Re: nest quote matching between { }

Post by Bushmills » 21 May 2016 12:57

"...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 ...

Locked