7

私はデフォルトのヘッダとして使用したいhaml-partialを作成しました。これをレンダリングするときに、デフォルトのコンテンツの一部を置き換えるブロックを与えたいと思うこともあります。Rails 4、haml内のオプションのブロックで部分/レイアウトをレンダする

私が試した複数のもの:私は知らない

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 

その他のオプション?

答えて

13

ブロックが必要な場合はrender layout: ""を使用してください。

ブロックを使用しない場合はrender partial: ""を使用してください。

彼らは地元の人と一緒に働き、あらかじめアンダースコアのファイルを探します。

関連する問題