我<head>出于性能原因加载了样式表和js文件.
我的网站有多个组件,每个模板都希望在里面有自己的额外头文件<% yield(:head).
我测试了<% content_for :head do %>..然后我意识到它实际上是覆盖而不是附加到特定部分.
你们用的是什么?
content_for实际上默认附加.从文档中,如果你要做...
<% content_for :navigation do %>
<li><%= link_to 'Home', :action => 'index' %></li>
<% end %>
<%# Add some other content, or use a different template: %>
<% content_for :navigation do %>
<li><%= link_to 'Login', :action => 'login' %></li>
<% end %>
Run Code Online (Sandbox Code Playgroud)
如果你用过...
<ul><%= content_for :navigation %></ul>
Run Code Online (Sandbox Code Playgroud)
它会输出......
<ul>
<li><a href="/">Home</a></li>
<li><a href="/login">Login</a></li>
</ul>
Run Code Online (Sandbox Code Playgroud)
刚刚在rails 3.1.0应用程序上本地测试了这一点,以确保仍然如此,它做得很好.
| 归档时间: |
|
| 查看次数: |
2283 次 |
| 最近记录: |