Module: Bridgetown::Builders::DSL::Hooks
- Included in:
- PluginBuilder
- Defined in:
- lib/bridgetown-builder/dsl/hooks.rb
Instance Method Summary collapse
-
#add_data(data_key) ⇒ Object
Define a site post_read hook and add data returned by the block to the site data/signals.
-
#hook(owner, event, method_name = nil, priority: Bridgetown::Hooks::DEFAULT_PRIORITY, &block) ⇒ Object
Define a hook to run at some point during the build process.
Instance Method Details
#add_data(data_key) ⇒ Object
Define a site post_read hook and add data returned by the block to the site data/signals
28 29 30 31 32 33 34 35 |
# File 'lib/bridgetown-builder/dsl/hooks.rb', line 28 def add_data(data_key) hook(:site, :post_read) do yield.tap do |value| site.data[data_key] = value site.signals[data_key] = value end end end |
#hook(owner, event, method_name = nil, priority: Bridgetown::Hooks::DEFAULT_PRIORITY, &block) ⇒ Object
Define a hook to run at some point during the build process
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/bridgetown-builder/dsl/hooks.rb', line 14 def hook( owner, event, method_name = nil, priority: Bridgetown::Hooks::DEFAULT_PRIORITY, &block ) block = method(method_name) if method_name.is_a?(Symbol) hook_block = Bridgetown::Hooks.register_one(owner, event, priority:, &block) functions << { name:, hook: [owner, event, priority, hook_block] } end |