加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – Rails 4,使用haml中的可选块渲染部分/布局

发布时间:2020-12-17 04:19:07 所属栏目:百科 来源:网络整理
导读:我创建了一个haml-partial,我想将其用作默认标头.渲染时,我可以选择给它一个块来替换默认内容的一部分. 我尝试过多种方法: render partial: "partial",capture: do# Don't really know why I tried this,Syntax error ofcourse.render partial: "partial" d
我创建了一个haml-partial,我想将其用作默认标头.渲染时,我可以选择给它一个块来替换默认内容的一部分.

我尝试过多种方法:

render partial: "partial",capture: do
# Don't really know why I tried this,Syntax error ofcourse.

render partial: "partial" do
# 'nil' is not an ActiveModel-compatible object. It must implement :to_partial_path.

render layout: "partial" do
# Works,but:

render layout: "partial"
# You invoked render but did not give any of :partial,:template,:inline,:file or :text option.
# So,it always needs the block

还有其他我不知道的选择吗?

解决方法

使用渲染布局:“”需要块时.

使用render partial:“”不使用块时.

他们都与当地人合作并寻找预先强调的文件.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读