Although I know that I can use "e, I was wondering if there was a less blunt and long way, such as \", or the like.
Here is an example of the XML:
<root name="test" type="Node" action="{puts :ROOT.to_s}">
<leaf type="Node" decider="{print :VAL1.to_s; gets.chomp.to_i}" action="{puts :ONE.to_s}" />
<leaf type="Node" decider="{print :VAL2.to_s; gets.chomp.to_i}" action="{puts :TWO.to_s}" />
<branch type="Node" decider="{100}" action="{}">
<leaf type="LikelihoodNode" decider="{100}" action="{puts :HI.to_s}" arg="0"/>
</branch>
</root>
The attributes that need this are decider and action. Right now the embedded code is using a little :sym.to_s hack, but that is not a solution.
NOTE: Although the action attribute is only a block in brackets, the processing code pre-pends the lambda.
A double quote inside an XML attribute is written as
"e;(or"or"). You’ll have similar issues with single quotes too so you can’t use those. However, you can use%as-is in an XML attribute so%|...|,%Q|...|, and%q|...|are available and they’re as easy to read and type as quotes:Choose whichever delimiters you find the easiest to type and read.
You can also use single quotes for your attributes in XML so you can have:
But then you’d have to use
'inside the attribute if you needed to include a single quote.Alternatively, you could switch to elements instead of attributes:
but that’s a bit verbose, ugly, and not as easy to work with as attributes (IMHO).