class BackboneGenerator::ViewGenerator
Abstract base class for generating views A.K.A copying template @author Tawheed Abdul-Raheem
Public Class Methods
create_view(view_name)
click to toggle source
# File lib/backbone_generator/generators/views/views_generator.rb, line 11 def create_view view_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 view_hash = { :app_name => app_name.slice(0,1).capitalize + app_name.slice(1..-1), :view_name => view_name.slice(0,1).capitalize + view_name.slice(1..-1), } template_path = File.expand_path(File.dirname(__FILE__)) + "/template/View.tt" target_path = "/js/views/" + view_hash[:view_name] + ".View.js" 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, view_hash) print "created ".green puts view_hash[:app_name] + target_path BackboneGenerator::TemplateGenerator.create_template(view_name) end end