1
我想創建自己的看法抽象成分,不透露他們將要呈現的方式。 該示例是一個選項卡式導航盒,如tabs from bootstrapDRY視分量的意見
在我看來,我想寫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>
我推遲標籤'內容'渲染失敗的所有嘗試都失敗了。我創建了一個minimal rails app,演示了我採用的三種方法。
看看的application_helper.rb和歡迎#放映視圖。 做這種事情的正確方法是什麼?