Support custom templates in the user's ~/.middleman directory
This commit is contained in:
parent
8886a74e89
commit
a6d2370fc4
|
@ -19,13 +19,18 @@ module Middleman::Templates
|
|||
include Thor::Actions
|
||||
|
||||
argument :location, :type => :string
|
||||
class_option :css_dir, :default => "stylesheets", :desc => 'The path to the css files'
|
||||
class_option :js_dir, :default => "javascripts", :desc => 'The path to the javascript files'
|
||||
class_option :images_dir, :default => "images", :desc => 'The path to the image files'
|
||||
class_option :template, :default => "default"
|
||||
class_option :css_dir, :default => "stylesheets"
|
||||
class_option :js_dir, :default => "javascripts"
|
||||
class_option :images_dir, :default => "images"
|
||||
end
|
||||
end
|
||||
|
||||
# Default template
|
||||
require "middleman/templates/default"
|
||||
|
||||
# HTML5 template
|
||||
require "middleman/templates/html5"
|
||||
require "middleman/templates/html5"
|
||||
|
||||
# Local templates
|
||||
require "middleman/templates/local"
|
20
lib/middleman/templates/local.rb
Normal file
20
lib/middleman/templates/local.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
module Middleman
|
||||
def self.templates_path
|
||||
File.join(`cd ~ && pwd`.chomp, ".middleman")
|
||||
end
|
||||
end
|
||||
|
||||
class Middleman::Templates::Local < Middleman::Templates::Base
|
||||
def self.source_root
|
||||
Middleman.templates_path
|
||||
end
|
||||
|
||||
def build_scaffold
|
||||
directory options[:template].to_s, location
|
||||
end
|
||||
end
|
||||
|
||||
Dir[File.join(Middleman.templates_path, "*")].each do |dir|
|
||||
next unless File.directory?(dir)
|
||||
Middleman::Templates.register(File.basename(dir).to_sym, Middleman::Templates::Local)
|
||||
end
|
Loading…
Reference in a new issue