将 Ruby 嵌入 nanoc 站点无效
Embedding Ruby into a nanoc site doesn't work
当我尝试在 Ruby 中循环遍历 sorted_articles()
时,嵌入的代码保持不变,并且在我 运行 [=16= 时不会在输出中编译].为什么是这样?我嵌入错了吗?我已经尝试了以下所有变体:
<%= for item in sorted_articles()
<p>item[:title]</p>
end %>
还有
<% for item in sorted_articles() %>
<p>item[:title]</p>
<% end %>
和
<% sorted_articles().each do |item| %>
<p>item[:title]</p>
<% end %>
最后
<%= sorted_articles().each do |item|
<p>item[:title]</p>
end %>
我也跟着教程 here 和我找到的差不多,但还是不走运!路由在起作用,规则和其他一切也在起作用。就是这个该死的循环!
上找到来源
所有 .html
文件的编译规则都没有通过 erb
过滤器,正如 Sergio 在评论中提到的那样,代码被忽略了。添加 filter :erb
解决了问题
当我尝试在 Ruby 中循环遍历 sorted_articles()
时,嵌入的代码保持不变,并且在我 运行 [=16= 时不会在输出中编译].为什么是这样?我嵌入错了吗?我已经尝试了以下所有变体:
<%= for item in sorted_articles()
<p>item[:title]</p>
end %>
还有
<% for item in sorted_articles() %>
<p>item[:title]</p>
<% end %>
和
<% sorted_articles().each do |item| %>
<p>item[:title]</p>
<% end %>
最后
<%= sorted_articles().each do |item|
<p>item[:title]</p>
end %>
我也跟着教程 here 和我找到的差不多,但还是不走运!路由在起作用,规则和其他一切也在起作用。就是这个该死的循环!
上找到来源所有 .html
文件的编译规则都没有通过 erb
过滤器,正如 Sergio 在评论中提到的那样,代码被忽略了。添加 filter :erb
解决了问题