我的规则文件中有这个:
compile '/gallery/' do
filter :haml
layout :'gallery'
end
...
compile '/' do
filter :haml
layout :'default'
end
...
route '/gallery/' do
nil
end
...
route '*' do
item.identifier.chop + '.' +item[:extension]
end
,所以现在我的 content/index.html 通过 haml 过滤器并编译为 output/index.html 一切都很好。我的 content/gallery.html 包含此代码,该代码也通过了 haml:
#gallery-container
%ul.items-small
%li.item
- @item.children.each do |img|
%a{:href => "#{img.path}"}
%ul.items-big
%li.item-big
- @item.children.each do |img|
%a{:href => "#"}
%figure
%img{:src => "#{img.path(:rep => :thumbnail)}"}
%figcaption.img-caption Caption
,它在文件夹中收集一些图像,content/gallery/
当我将路由设置为output/gallery/index.html
(查看预览输出吐出)时,我确实得到了我想要的,所以一切都很好。
但是现在我想将生成的代码用作我的部分代码content/index.html
,但是当我尝试包含它时,就像=render 'gallery'
我没有得到预期的代码一样。反过来我收到错误消息LocalJumpError: no block given (yield)
。
我的文件中应该有什么layouts/gallery.html
?,如果我放在那里,<%= yield %>
我会收到上述错误,如果我删除=render 'gallery'
没有错误,
但是如果我在我的 index.html 中输入一些文本layouts/gallery.html
并再次=render 'gallery'
在我的 index.html 中得到该文本layouts/gallery.html
,所以它被包括在内并且没有错误。那么我应该 <%= yield %> 我期待的画廊代码layouts/gallery.html
然后从 index.html 调用 =render 'gallery' 吗?但这不起作用。此外,它layouts/default.html
已经有自己的收益正在工作,然后我尝试在将通过该收益编译的项目中使用该 =render。我做错了吗?我搞不清楚了!
我所有的布局文件都被:erb
过滤了。
所以我的问题是如何包含这个部分。谢谢!