【发布时间】:2014-01-19 10:09:39
【问题描述】:
我的规则文件中有这个:
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' 没有错误,
但是,如果我在layouts/gallery.html 中添加一些文本,并在我的 index.html 中再次添加 =render 'gallery',我会在 layouts/gallery.html 中得到该文本,因此它会被包含在内并且不会出现错误。那么我应该 我期待的画廊代码到layouts/gallery.html 然后从 index.html 调用 =render 'gallery' 吗?但这不起作用。此外,layouts/default.html 已经有自己的收益正在工作,然后我尝试在将通过该收益编译的项目中使用该 =render。我做错了吗?我迷路了!
我所有的布局文件都经过:erb 过滤。
所以我的问题是如何包含这个部分。谢谢!
【问题讨论】:
标签: layout haml render partial nanoc