Update the extension template for the new Extension class.

This commit is contained in:
Ben Hollis 2013-04-12 19:56:52 -07:00
parent b607d70a52
commit f7cd0e231e

View file

@ -2,42 +2,39 @@
require "middleman-core" require "middleman-core"
# Extension namespace # Extension namespace
module MyExtension module MyExtension < Middleman::Extension
class << self option :my_option, "default", "An example option"
# Called when user `activate`s your extension def initialize(app, options_hash={})
def registered(app, options={}) # Call super to build options from the options_hash
# Include class methods super
# app.extend ClassMethods
# Include instance methods # Require libraries only when activated
# app.send :include, InstanceMethods # require 'necessary/library'
app.after_configuration do # Include helpers or instance methods for the Middleman app
# app.send :include, Helpers
# set up your extension
# puts options.my_option
end
def after_configuration
# Do something # Do something
end end
end
alias :included :registered
end
# module ClassMethods # module Helpers
# def a_class_method # def a_helper
# end
# end
# module InstanceMethods
# def an_instance_method
# end # end
# end # end
end end
# Register extensions which can be activated # Register extensions which can be activated
# Make sure we have the version of Middleman we expect # Make sure we have the version of Middleman we expect
# ::Middleman::Extensions.register(:extension_name) do # ::Middleman::Extensions.register(:extension_name) do
# #
# # Return the extension module # # Return the extension class
# ::MyExtension # ::MyExtension
# #
# end # end