非工作代码:
# application.html.erb, BASE layout
<html>
<head>
<body>
<%= yield %>
</body>
</head>
</html>
# _pwa.html.erb, SPECIFIC layout
<div class="container">
<%= yield :main_content %>
</div>
# _partial.html.erb, ACTUAL body
<% content_for :main_content do %>
<h1>Test</h1>
<% end %>
# view.html.erb, actual view file that links everything together
<%= render layout: "layouts/pwa" do %>
<%= render "partial" %>
<% end %>
当控制器呈现view.html.erb
时,我希望输出html文件看起来像这样:
<html>
<head>
<body>
<div class="container">
<h1>Test</h1>
</div>
</body>
</head>
</html>
但<h1>Test</h1>
实际上并不存在。另一方面,如果我删除了命名的yield,并且只是替换为常规yield,它确实有效。即,下面的代码确实生成了上面的正确输出:
工作代码:
# application.html.erb, BASE layout
<html>
<head>
<body>
<%= yield %>
</body>
</head>
</html>
# _pwa.html.erb, SPECIFIC layout
<div class="container">
<%= yield %>
</div>
# _partial.html.erb, ACTUAL body
<h1>Test</h1>
# view.html.erb, actual view file that links everything together
<%= render layout: "layouts/pwa" do %>
<%= render "partial" %>
<% end %>
但我确实想知道如何让命名区域工作,因为实际的pwa
布局有点复杂,我想做类似下面的事情:
# _pwa.html.erb
<div class="container">
<%= yield :main_content %>
</div>
<div class="container">
<%= yield :secondary_content %>
</div>
# _partial.html.erb
<% content_for :main_content do %>
<h1>Test</h1>
<% end %>
<% content_for :secondary_content do %>
<h2>Second</h2>
<% end %>
编辑,我实际上有一个像这样的迭代器:
<%= render layout: "layouts/pwa" do %>
<% @pages.each do |p| %>
<%= render "partial/#{p}" %>
<% end %>
<% end %>
答案 0 :(得分:0)
感谢您的反馈!我最终做的是下面。这完成了:
查看文件层次结构
data = pd.read_csv('measurements.csv', decimal=',')
<强>代码强>
Symbol()