From f7cd0e231e1f56f6c8ea1b76c4b3b766fff1e92c Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Fri, 12 Apr 2013 19:56:52 -0700 Subject: [PATCH] Update the extension template for the new Extension class. --- .../templates/extension/lib/lib.rb | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/middleman-core/lib/middleman-core/templates/extension/lib/lib.rb b/middleman-core/lib/middleman-core/templates/extension/lib/lib.rb index 1eb1796c..c2aa42dc 100644 --- a/middleman-core/lib/middleman-core/templates/extension/lib/lib.rb +++ b/middleman-core/lib/middleman-core/templates/extension/lib/lib.rb @@ -2,42 +2,39 @@ require "middleman-core" # Extension namespace -module MyExtension - class << self +module MyExtension < Middleman::Extension + option :my_option, "default", "An example option" - # Called when user `activate`s your extension - def registered(app, options={}) - # Include class methods - # app.extend ClassMethods + def initialize(app, options_hash={}) + # Call super to build options from the options_hash + super - # Include instance methods - # app.send :include, InstanceMethods + # Require libraries only when activated + # require 'necessary/library' - app.after_configuration do - # Do something - end - end - alias :included :registered + # Include helpers or instance methods for the Middleman app + # app.send :include, Helpers + + # set up your extension + # puts options.my_option end - # module ClassMethods - # def a_class_method - # end - # end + def after_configuration + # Do something + end - # module InstanceMethods - # def an_instance_method + # module Helpers + # def a_helper # end # end end - # Register extensions which can be activated # Make sure we have the version of Middleman we expect # ::Middleman::Extensions.register(:extension_name) do # -# # Return the extension module +# # Return the extension class # ::MyExtension # # end