Class: Middleman::Templates::Base

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/middleman-core/templates.rb

Overview

Base Template class. Handles basic options and paths.

Direct Known Subclasses

Default, Empty, Html5, Local, Mobile, Smacss

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(names, options) ⇒ Base

Returns a new instance of Base.



32
33
34
35
# File 'lib/middleman-core/templates.rb', line 32

def initialize(names, options)
  super
  source_paths << File.join(File.dirname(__FILE__), 'templates')
end

Class Method Details

.gemfile_templateObject

The gemfile template to use. Individual templates can define this class method to override the template path.



39
40
41
# File 'lib/middleman-core/templates.rb', line 39

def self.gemfile_template
  "shared/Gemfile.tt"
end

Instance Method Details

#generate_bundler!void

This method returns an undefined value.

Write a Bundler Gemfile file for project



64
65
66
67
68
69
70
71
72
# File 'lib/middleman-core/templates.rb', line 64

def generate_bundler!
  return if options[:'skip-gemfile']
  template self.class.gemfile_template, File.join(location, "Gemfile")

  return if options[:'skip-bundle']
  inside(location) do
    ::Middleman::Cli::Bundle.new.invoke(:bundle)
  end unless ENV["TEST"]
end

#generate_gitignore!void

This method returns an undefined value.

Write a .gitignore file for project



79
80
81
82
# File 'lib/middleman-core/templates.rb', line 79

def generate_gitignore!
  return if options[:'skip-git']
  copy_file "shared/gitignore", File.join(location, ".gitignore")
end

#generate_rack!void

This method returns an undefined value.

Write a Rack config.ru file for project



54
55
56
57
# File 'lib/middleman-core/templates.rb', line 54

def generate_rack!
  return unless options[:rack]
  template "shared/config.ru", File.join(location, "config.ru")
end