Nanoc compile rule with regex

115 Views Asked by At

I have files with filenames begining with controls-, like controls-dark.png for example, but this rule does not catch them:

compile '/gallery/*/', :rep => :thumbnail do
  filter :thumbnailize, :width => 200 unless /controls-/.match(item[:filename])
end

Why does this not gives a match?

So at the end I get controls-dark.png converted to thumbnail although it should be excluded by this rule.

1

There are 1 best solutions below

0
On

Actually it was working, problem was in routing, so it did not convert my controls-dark.png to thumbnail, only changed its filename to conrols-dark-thumbnail.png.

I used the same check in routes, so:

route '/gallery/*/', :rep => :thumbnail do
unless /controls-/.match(item[:filename])
    item.identifier.chop + '-thumbnail.' + item[:extension]
else
    item.identifier.chop + '.' + item[:extension]
end

Now files containing controls- in their filename get only copied over, without -thumbnail suffix appended.