0
當我使用yield_content
時,我在頁面中看到奇怪的輸出。請看下面。 注意[#<Proc:[email protected]/home/akonsu/project/index.erb:1>]
部分。這是什麼?yield_content的多餘輸出
layout.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:[email protected]/home/akonsu/project/index.erb:1>]
</head>
<body>
<div id="contents">
...
</div>
</body>
</html>