alias the builder callbacks more easily
This commit is contained in:
parent
8c07dd3f97
commit
0303ed6442
4 changed files with 31 additions and 1 deletions
|
@ -77,6 +77,9 @@ module Middleman
|
|||
end
|
||||
|
||||
module CoreExtensions
|
||||
# Add Builder callbacks
|
||||
autoload :Builder, "middleman/core_extensions/builder"
|
||||
|
||||
# Add Rack::Builder.map support
|
||||
autoload :RackMap, "middleman/core_extensions/rack_map"
|
||||
|
||||
|
|
|
@ -29,6 +29,9 @@ module Middleman::Base
|
|||
|
||||
app.set :views, "source"
|
||||
|
||||
# Add Builder Callbacks
|
||||
app.register Middleman::CoreExtensions::Builder
|
||||
|
||||
# Add Rack::Builder.map to Sinatra
|
||||
app.register Middleman::CoreExtensions::RackMap
|
||||
|
||||
|
|
|
@ -76,6 +76,10 @@ module Middleman
|
|||
@@hooks.each do |name, proc|
|
||||
instance_eval(&proc)
|
||||
end
|
||||
|
||||
SHARED_SERVER.after_build_callbacks.each do |name, proc|
|
||||
instance_eval(&proc)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
20
lib/middleman/core_extensions/builder.rb
Normal file
20
lib/middleman/core_extensions/builder.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
module Middleman::CoreExtensions::Builder
|
||||
class << self
|
||||
def registered(app)
|
||||
app.extend ClassMethods
|
||||
end
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
# Add a block/proc to be run after features have been setup
|
||||
def after_build(&block)
|
||||
@run_after_build ||= []
|
||||
@run_after_build << block
|
||||
end
|
||||
|
||||
def after_build_callbacks
|
||||
@run_after_build ||= []
|
||||
@run_after_build
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue