Support custom templates in the user's ~/.middleman directory

This commit is contained in:
Thomas Reynolds 2011-04-16 16:23:10 -07:00
parent 8886a74e89
commit a6d2370fc4
2 changed files with 29 additions and 4 deletions

View file

@ -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"

View 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