Now I know how to build xml without escaping values. How to tell Builder to not to escape values
However I need to build tags dynamically.
Desired result
<bank_info>Chase</bank_info>
What I have is
attr = 'bank_info'
builder = Builder::XmlMarkup.new
builder.attr { |x| x << 'bank_info' } # does not work
I can try making the whole thing as a giant string and eval that. But evaling is not that safe. Is there a better option that I am missing.
In general, the simplest way to call a method for which you have a name is to use
sendor__send__. Here:BTW, there is the variant
public_send, in case you want to insure you are not calling a private method. It’s only in Ruby 1.9, you canrequire "backports"to use it in Ruby 1.8.Note: in this case,
senddoesn’t work, as pointed out by @KandadaBoggu, because Builder overrides it; you must use__send__.