論盡蛋
心で書く

Blog


How to write Javascript bookmarklet


Rails layout for XML builder

Github repo for the example code: CeXMLLayout

The example code shows how to use layout for xml builder.

If you create app/views/layout/application.xml.builder and simply add a yield inside it, you will find that the yield actually not working very well.

There are more detailed description inside the github repo. Here is the short answer:

#!ruby
xml.instruct!
xml.root do
  xml << yield
  # or
  xml << yield.gsub(/^/, ) # To add 2 spaces before each line in the yielded content, or else the indentation won't be correct.
end