ビューの抽象コンポーネントを作成したいのですが、それらがレンダリングされる方法を明らかにしていません。例は、ブートストラップのタブのようなタブ付きのナビゲーション ボックスです。
私の見解では、s.thを書きたいと思います。お気に入り:
= tab_section(self) do
- tab 'tab1' do
%p tab1 content
= link_to example_var, "#top"
- tab 'tab2' do
%p tab2 content
= link_to 'http://example.com', "#top"
次に、s.thにレンダリングする必要があります。このような:
<ul>
<li>tab1</li>
<li>tab2</li>
</ul>
<div class='content'>
<div class='tab'>
<p>tab1 content</p>
<a href='#top'>this could also be an @var from the controller</a>
</div>
<div class='tab'>
<p>tab2 content</p>
<a href='#top'>http://example.com</a>
</div>
</div>
タブ「コンテンツ」のレンダリングを延期する試みはすべて失敗しました。私が取った 3 つのアプローチを示す最小限の Rails アプリを作成しました。
application_helper.rb とwelcome#show ビューを見てください。そのようなことを行う正しい方法は何ですか?