Rails 4,使用haml中的可选块渲染部分/布局

时间:2013-10-31 14:58:15

标签: ruby-on-rails ruby-on-rails-4 rendering haml partial-views

我创建了一个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

我不知道的其他选择?

1 个答案:

答案 0 :(得分:13)

需要阻止时使用render layout: ""

不使用块时使用render partial: ""

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

相关问题