Rails 3 中 XML 构建器的布局

发布于 2024-11-18 14:17:09 字数 324 浏览 7 评论 0原文

我想为 XML 响应创建通用布局文件。例如,我想将 RSS 的一般部分包装在布局中,并将内容保留在相应的视图文件中生成。

例如,

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

  yield

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

因此项目显示视图无需担心 RSS 包装。

然而,yield 不起作用,只渲​​染了布局,但视图没有返回任何内容。

请帮忙。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

So尛奶瓶 2024-11-25 14:17:09

尝试:

xml.instruct!
  xml << yield

Try:

xml.instruct!
  xml << yield
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文