lib/middleman/templates.rb in middleman-3.0.0.alpha.4 vs lib/middleman/templates.rb in middleman-3.0.0.alpha.5
- old
+ new
@@ -7,22 +7,24 @@
# Static methods
class << self
# Get list of registered templates and add new ones
+ #
+ # Middleman::Templates.register(:ext_name, klass)
#
# @param [Symbol] name The name of the template
# @param [Class] klass The class to be executed for this template
# @return [Hash] List of registered templates
- def registered(*args)
+ def register(*args)
@_template_mappings ||= {}
@_template_mappings[args[0]] = args[1] if args.length == 2
@_template_mappings
end
# Middleman::Templates.register(name, klass)
- alias :register :registered
+ alias :registered :register
end
# Base Template class. Handles basic options and paths.
class Base < ::Thor::Group
include Thor::Actions
@@ -42,17 +44,23 @@
# What to call the directory which images will be searched for.
class_option :images_dir, :default => "images"
# Output a config.ru file for Rack if --rack is passed
class_option :rack, :type => :boolean, :default => false
- def generate_rack
+
+ # Write a Rack config.ru file for project
+ # @return [void]
+ def generate_rack!
return unless options[:rack]
template "shared/config.ru", File.join(location, "config.ru")
end
# Output a Gemfile file for Bundler if --bundler is passed
class_option :bundler, :type => :boolean, :default => false
- def generate_bundler
+
+ # Write a Bundler Gemfile file for project
+ # @return [void]
+ def generate_bundler!
return unless options[:bundler]
template "shared/Gemfile.tt", File.join(location, "Gemfile")
say_status :run, "bundle install"
print `cd #{location} && "#{Gem.ruby}" -rubygems "#{Gem.bin_path('bundler', 'bundle')}" install`
\ No newline at end of file