当我使用yield_content
. 请看下文。注意[#<Proc:0x850a14c@/home/akonsu/project/index.erb:1>]
部分。这是什么?
布局.erb:
<!DOCTYPE html>
<html>
<head>
<%= yield_content :head %>
</head>
<body>
<%= yield %>
</body>
</html>
index.erb:
<% content_for :head do %>
<script type="text/javascript" src="/js/jquery.js"></script>
<% end %>
<div id="contents">
...
</div>
输出:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="/js/jquery.js"></script>
[#<Proc:0x850a14c@/home/akonsu/project/index.erb:1>]
</head>
<body>
<div id="contents">
...
</div>
</body>
</html>