如何在没有布局的帮助器中呈现视图/部分? [英] How to render a view/partial in a helper w/o the layout?

查看:24
本文介绍了如何在没有布局的帮助器中呈现视图/部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在做以下工作:

Hello in a helper I'm doing the following:

render(:template =>"feeds/_feed_item.html.erb", :locals => { :feed_item => feed_item }).to_s

问题是这是渲染我不想要的布局.如何仅呈现文件/模板 feed_item ?

Problem is this is rendering the layout which I don't want. How can I render just the file/template feed_item ?

谢谢

推荐答案

您可以添加选项 :layout =>false 在没有布局的情况下渲染.

You can add the option :layout => false to render without the layout.

示例:

render(:template =>"feeds/_feed_item.html.erb", :layout => nil , :locals => { :feed_item => feed_item }).to_s

这篇关于如何在没有布局的帮助器中呈现视图/部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆