Update local extension template

This commit is contained in:
Thomas Reynolds 2015-12-20 12:48:01 -08:00
parent 5d0f12e6ca
commit 6aeda854c0
4 changed files with 36 additions and 38 deletions

View file

@ -30,8 +30,8 @@ module Middleman::Cli
template 'extension/Rakefile', File.join(name, 'Rakefile') template 'extension/Rakefile', File.join(name, 'Rakefile')
template 'extension/gemspec', File.join(name, "#{name}.gemspec") template 'extension/gemspec', File.join(name, "#{name}.gemspec")
template 'extension/Gemfile', File.join(name, 'Gemfile') template 'extension/Gemfile', File.join(name, 'Gemfile')
template 'extension/lib/middleman_extension.rb', File.join(name, 'lib', 'middleman_extension.rb')
template 'extension/lib/lib.rb', File.join(name, 'lib', "#{name}.rb") template 'extension/lib/lib.rb', File.join(name, 'lib', "#{name}.rb")
template 'extension/lib/lib/extension.rb', File.join(name, 'lib', name, "extension.rb")
template 'extension/features/support/env.rb', File.join(name, 'features', 'support', 'env.rb') template 'extension/features/support/env.rb', File.join(name, 'features', 'support', 'env.rb')
empty_directory File.join(name, 'fixtures') empty_directory File.join(name, 'fixtures')
end end

View file

@ -1,38 +1,6 @@
# Require core library require "middleman-core"
require 'middleman-core'
# Extension namespace Middleman::Extensions.register :<%= name %> do
class MyExtension < ::Middleman::Extension require "my-extension/extension"
option :my_option, 'default', 'An example option' MyExtension
def initialize(app, options_hash={}, &block)
# Call super to build options from the options_hash
super
# Require libraries only when activated
# require 'necessary/library'
# set up your extension
# puts options.my_option
end
def after_configuration
# Do something
end
# A Sitemap Manipulator
# def manipulate_resource_list(resources)
# end
# helpers do
# def a_helper
# end
# end
end end
# Register extensions which can be activated
# Make sure we have the version of Middleman we expect
# Name param may be omited, it will default to underscored
# version of class name
# MyExtension.register(:my_extension)

View file

@ -0,0 +1,31 @@
# Require core library
require 'middleman-core'
# Extension namespace
class MyExtension < ::Middleman::Extension
option :my_option, 'default', 'An example option'
def initialize(app, options_hash={}, &block)
# Call super to build options from the options_hash
super
# Require libraries only when activated
# require 'necessary/library'
# set up your extension
# puts options.my_option
end
def after_configuration
# Do something
end
# A Sitemap Manipulator
# def manipulate_resource_list(resources)
# end
# helpers do
# def a_helper
# end
# end
end