How to build a builder dynamically with escaped values

Posted by dorelal on Stack Overflow See other posts from Stack Overflow or by dorelal
Published on 2010-04-22T18:09:10Z Indexed on 2010/04/22 18:13 UTC
Read the original article Hit count: 193

Filed under:
|
|

Now I know how to build xml without escaping values. http://stackoverflow.com/questions/2693036/how-to-tell-bulider-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.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby