1
對不起,我不會使用英文的具體表達。如何糾正在Sinatra秀塊
index.erb
<h1>Hello World.</h1>
<ul>
<li>item1</li>
<li>item2</li>
</ul>
<% capture_content :key do %>
I'm Here.
<% end %>
helpers
def capture_content(key, &block)
@content_hash = {}
@content_hash[key] = block.call # this block contains erb all
end
我只想capture_content
內容
我希望表達的是正確的T_T
你想達到什麼目的? – gmaliar 2013-02-24 14:42:05
我想@content_hash [:key] ='我在這裏' – kennx9 2013-02-24 14:46:53
也許Sinatra :: Contrib中的[Sinatra :: ContentFor](http://www.sinatrarb.com/contrib/content_for.html)你的需要? – nemesv 2013-02-24 14:58:51