In Groovy double quotes must not be escaped inside single quote strings. The opposite also applies: single quotes must not be escaped inside double quote strings (known as GStrings, by the way)
Try
<g:form ${true ? 'name="hello"' : ''}>
or
<g:form ${true ? "name=\"hello\"" : ''}>
Both will work.
For the second part of the updated question I would recommend to build the map separately as it is not only going to work but your code is going to be easier to read and maintain. Something like:
<%
def urlMap = [action: 'update']
if(multiple)
urlMap.put 'resource', 'xyzInstance'
%>
<g:form url="${urlMap}" method="PUT">
Be careful also with the types you use as values on some attributes, this has caused me some troubles sometimes:
- 'a String'
- "a GString with a ${dynamicValue}"
- "[a GString that looks like a list]"
- "${[a, list]}"
- "${[a: map]}"
- "false" <- This will always be evaluated to true, as it's a non-empty non-null GString
- "${false}" <- Solution to the problem of the line above
I hope all this solve your problems. For simplicity's sake I'd always recommend to keep value expressions as simple as possible, and if they need complex logic put it in a block immediately before the tag it's gonna benefit from it.