Class: BackboneGenerator::TemplateGenerator
- Inherits:
-
Object
- Object
- BackboneGenerator::TemplateGenerator
- Defined in:
- lib/backbone_generator/generators/templates/templates_generator.rb
Overview
Abstract base class for generating utility A.K.A copying template
Class Method Summary collapse
Class Method Details
.create_template(template_name) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/backbone_generator/generators/templates/templates_generator.rb', line 11 def create_template template_name app_name = BackboneGenerator.option_details[:app_name] || File.basename(Dir.getwd).chomp("/") if BackboneGenerator.option_details[:app_name] dir_path = File.join(Dir.getwd, app_name) else dir_path = File.join(Dir.getwd) end template_hash = { :app_name => app_name.slice(0,1).capitalize + app_name.slice(1..-1), :template_name => template_name.slice(0,1).capitalize + template_name.slice(1..-1), } template_path = File.(File.dirname(__FILE__)) + "/template/Template.tt" target_path = "/js/templates/" + template_hash[:template_name] + ".Template.html" if File.exist? dir_path + target_path print "error ".red puts "View with the name specified already exists" else BackboneGenerator.compile_and_copy(template_path, dir_path + target_path, template_hash) print "created ".green puts template_hash[:app_name] + target_path end end |