我希望每个视图文件都有自己的布局,因为每个视图都需要在<head>
标记中使用不同的脚本运行不同的脚本,但它们仍然应该从layouts/application.html.erb
继承相同的内容。这可能吗?
layouts / application.html.erb - &gt; layouts / a.html.erb - &gt;视图/ a.index.html.erb
layouts / application.html.erb - &gt; layouts / b.html.erb - &gt;视图/ b.index.html.erb
答案 0 :(得分:1)
content_for :header_tags
用于向<head>
或application.html.erb
的{{1}}添加额外的行。以下是base.html.erb
的实例:
whatever.html.erb
然后<% content_for :header_tags do %>
<%= javascript_include_tag :redmine_helpdesk, :plugin => 'redmine_contacts_helpdesk' %>
<%= stylesheet_link_tag :helpdesk, :plugin => 'redmine_contacts_helpdesk' %>
<% end %>
调用base.html.erb
来表达使用:header_tags键存储的内容。