Low priority hooks are being run before higher priority hooks. This is easy to
demonstrate with the following plugin:
1.upto(10).each do |n|
Jekyll::Hooks.register :site, :after_reset, priority: Jekyll::Hooks::PRIORITY_MAP[:low] do
puts "Low #{n}"
end
Jekyll::Hooks.register :site, :after_reset, priority: Jekyll::Hooks::PRIORITY_MAP[:normal] do
puts "Normal #{n}"
end
Jekyll::Hooks.register :site, :after_reset, priority: Jekyll::Hooks::PRIORITY_MAP[:high] do
puts "High #{n}"
end
end
Sorting by the negative of the priority and then by the order the hook was
added does the right thing.
- hooks are registered to symbol owners rather than classes directly
- during registration, add the ability to specify owner as an array to
register the same hook to multiple owners
- add optional priority during registration as a symbol (:low, :normal,
:high)
- implement hooks for collections as they are in octopress-hooks, aside
from post_init