ruby-on-railslayoutyieldxml-builder

layout for XML builder in rails 3


I would like to create general layout file for XML response. For example I would like to wrap those general part of RSS in the layout and leave the content be generated in the corresponding view file.

For example,

# in layout/rss.xml.builder
xml.instruct!
...... # other general stuff for RSS

  yield

# in items/show.xml.builder
xml.item ......

So the item show view no need to worry the RSS wrappings.

However the yield is not working and only the layout is rendered, but the view returned nothing.

Please help.


Solution

  • Try:

    xml.instruct!
      xml << yield