#8 Layouts and content_for

If you want to change something in the layout on a per-template basis, content_for is your answer! This allows templates to specify view code that can be placed anywhere in a layout.
<!-- projects/index.rhtml -->
<% content_for :head do %>
  <%= stylesheet_link_tag 'projects' %>
<% end %>

<!-- layouts/application.rhtml -->
<head>
  <title>Todo List</title>
  <%= stylesheet_link_tag 'application' %>
  <%= yield :head %>
</head>

你可能感兴趣的:(java)