Open 0x1eef opened 2 years ago
Hey there,
At the moment, the easiest (though a little repetitive) way to do this is to call :minify
after the layout:
compile '/**/*.md' do
filter :kramdown
layout '/default.*'
filter :minify
end
layout '/**/*.erb', :erb
The filter :minify
is called separately after the layout
call. (A compilation rule evaluates its steps in order, one after another.)
If two filters always need to happen in succession, then it might be worth having a way to explicitly combine filters. Something like this:
Nanoc::Filter.combine([:erb, :minify] => :my_erb)
(You’d still need to define your own :minify
filter in this example.)
If two filters always need to happen in succession, then it might be worth having a way to explicitly combine filters. Something like this:
Nanoc::Filter.combine([:erb, :minify] => :my_erb)
That seems nice !
This is what I had imagined:
layout '**/*', [:erb, :minify]
I could see this working too:
layout '**/*', Nanoc::Filter.combine([:erb, :minify])
My only suggestion would be to not make a name of the combined filters required. I think it can be redundant (like in the examples above), and introduce a new filter name that is kind of strange (like :my_erb
).
Thanks!
Hey :wave: I'm cleaning up my issue list. Not clear if this one is actionable or not. Please feel free to close if it is taking up space among legitimate issues.
Hello !
I would like to first say, thank you for all your work on nanoc. I love it ! This issue is a feature request (maybe it's already possible, but I couldn't figure out how).
I would like to apply multiple filters to a layout - at the moment I could only figure out how to apply one filter (eg
erb
). The reason is that I would like to run theerb
filter, followed by a custom filter that minifies the result of theerb
filter.The solution I came up with is this - but it is less than ideal because it implies using
erb
all the time, and I didn't see an easy way to avoid that.Gist: