Merge pull request #920 from bhollis/empty

Add an "empty" template and let template classes override the "Gemfile" template.
This commit is contained in:
Thomas Reynolds 2013-05-31 06:49:57 -07:00
commit 8cf25c7cc3
4 changed files with 40 additions and 3 deletions

View file

@ -12,6 +12,9 @@
3.1.0.rc.2
===
* Custom template classes can now override the file used for creating the project Gemfile.
* Add an "empty" template that produces the minimum necessary structure for a Middleman project.
* Fix ignoring layouts from the sitemap when the source directory has been set to something other than 'source'. #896
* Track test coverage with simplecov
* i18n only autodetects languages in the `locales` root
* Frontmatter cache fixes solve performance regressions found in 3.1.x
@ -22,7 +25,6 @@
3.1.0.rc.1
===
* Fix ignoring layouts from the sitemap when the source directory has been set to something other than 'source'. #896
* Move more into core, autoloaded if gems are available.
* DataStore may now be accessed like a hash with #[] and #has_key?. #880
* The i18n extension now supports providing localized templates as separate files, like index.es.html.haml. #816, #823

View file

@ -34,6 +34,12 @@ module Middleman::Templates
source_paths << File.join(File.dirname(__FILE__), 'templates')
end
# The gemfile template to use. Individual templates can define this class
# method to override the template path.
def self.gemfile_template
"shared/Gemfile.tt"
end
# Required path for the new project to be generated
argument :location, :type => :string
@ -57,7 +63,7 @@ module Middleman::Templates
# @return [void]
def generate_bundler!
return if options[:'skip-gemfile']
template "shared/Gemfile.tt", File.join(location, "Gemfile")
template self.class.gemfile_template, File.join(location, "Gemfile")
return if options[:'skip-bundle']
inside(location) do
@ -90,4 +96,7 @@ require "middleman-core/templates/mobile"
require "middleman-more/templates/smacss"
# Local templates
require "middleman-core/templates/local"
require "middleman-core/templates/local"
# Barebones template
require "middleman-core/templates/empty"

View file

@ -0,0 +1,23 @@
# A barebones template with nothing much in it
class Middleman::Templates::Empty < Middleman::Templates::Base
# Template files are relative to this file
# @return [String]
def self.source_root
File.dirname(__FILE__)
end
def self.gemfile_template
"empty/Gemfile.tt"
end
# Actually output the files
# @return [void]
def build_scaffold!
create_file File.join(location, "config.rb"), "\n"
empty_directory File.join(location, "source")
end
end
# Register this template
Middleman::Templates.register(:empty, Middleman::Templates::Empty)

View file

@ -0,0 +1,3 @@
source 'https://rubygems.org'
gem "middleman", "~><%= Middleman::VERSION %>"