Nanocomposition and multiple layouts

Can I use multiple layouts for a specific (or all) of the item (s)? For example, I have a couple of elements, and I want to apply two different layouts to it. One with green and one with a blue background (however). And I want to compile them in two different folders in my output directory (e.g. v1 and v2).

I played with rules and compilation blocks, but I could not figure out how this could work. Since each element is compiled only once during the compilation process, I cannot say that nanoc will compile it the first time with layout1 and the second time with layout2. I tried it like this, but it caused the output files to crash.

compile '*' do
  if item.binary?
    # don’t filter binary items
  else
    filter :erb
    layout 'layout1'
    layout 'layout2'
  end
end

Hope I made it clear and someone can help.

THX, Tux

+5
1

. , . , , :

# 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
end
+9

All Articles