是否可以对特定(或所有)项目使用多个布局?例如,我有几个项目,我想对其应用两种不同的布局。一个是绿色的,另一个是蓝色的(但是)。我想把它们编译到我的输出目录中的两个不同的文件夹中(例如v1和v2)。
我在玩弄规则和编译代码块,但我不知道这是如何工作的。因为,每个项目在编译过程中只编译一次,我不能告诉nanoc第一次用layout1编译,第二次用layout2编译。我尝试了这样的东西,但它导致输出文件损坏。
compile '*' do
if item.binary?
# don’t filter binary items
else
filter :erb
layout 'layout1'
layout 'layout2'
end
end希望我说得很清楚有人能帮上忙。
thx,tux
发布于 2011-08-27 15:30:37
项表示就是为了达到这个目的。您可以创建两种不同的表示法,例如默认表示法和备用表示法,然后对它们应用编译和路由规则,如下所示:
# default rep, although you can pass
# :rep => :default explicitly too
compile '/stuff/*/' do
filter :erb
layout 'default'
end
route '/stuff/*/' do
# /stuff/foo/ -> /boring/stuff/foo/
# Just an example; you probably need something else
'/boring' + item.identifier
end
compile '/stuff/*/', :rep => :special do
filter :erb
layout 'special' # this is different
end
route '/stuff/*/', :rep => :special do
# /stuff/foo/ -> /special/stuff/foo/
# Again, just an example
'/special' + item.identifier
endhttps://stackoverflow.com/questions/7162517
复制相似问题