Using layouts for XML Builder(RXML) in Ruby on Rails

If you are using .builder files (formerly rxml)  for generating XML files in Ruby on Rails, you can avail the power of layouts. But XML layouts are handled slightly different from HTML layouts. You might be tempted to write the following layout code

but that will result in an error. What you need is the following.

If @message is "Hello World" and @status is "Success", then using layouts this will result in

Happy Coding!

blog comments powered by Disqus