开发者

How to render a view/partial in a helper w/o the layout?

Hello in a helper I'm doing the following:

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

Problem is this is rendering the layout开发者_StackOverflow中文版 which I don't want. How can I render just the file/template feed_item ?

Thanks


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

Example:

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


If you use the :partial key, the template shouldn't be rendered. Try this:

render :partial => 'feeds/feed_item', :locals => { :feed_item => feed_item }).to_s

Depending on your setup, you may also be able to shorten this to simply:

render feed_item
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜