Class: Backbone::Generators::ScaffoldGenerator

Inherits:
ModelGenerator
  • Object
show all
Defined in:
lib/generators/backbone/scaffold/scaffold_generator.rb

Instance Method Summary collapse

Methods inherited from ModelGenerator

#create_backbone_model

Methods included from ResourceHelpers

#application_name, #backbone_path, #collection_namespace, #js_app_name, #jst, #model_namespace, #plural_model_name, #router_namespace, #singular_model_name, #uncapitalize, #view_namespace

Instance Method Details

#create_router_filesObject



13
14
15
16
17
18
19
# File 'lib/generators/backbone/scaffold/scaffold_generator.rb', line 13

def create_router_files 
  if options[:single]
    template 'router-sp.coffee', File.join(backbone_path, "routers", class_path, "#{plural_name}_router.js.coffee")
  else
    template 'router.coffee', File.join(backbone_path, "routers", class_path, "#{plural_name}_router.js.coffee")
  end
end

#create_view_filesObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/generators/backbone/scaffold/scaffold_generator.rb', line 21

def create_view_files
  available_views.each do |view|
    template "views/#{view}_view.coffee", File.join(backbone_path, "views", plural_name, "#{view}_view.js.coffee")
    template "templates/#{view}.jst", File.join(backbone_path, "templates", plural_name, "#{view}.jst.ejs")       
  end
  if options[:single]
    available_views.each do |view|
      template "views-sp/#{view}_view.coffee", File.join(backbone_path, "views", plural_name, "#{view}_view.js.coffee")
      template "templates-sp/#{view}.jst", File.join(backbone_path, "templates", plural_name, "#{view}.jst.ejs")       
    end
    
    template "views-sp/model_view.coffee", File.join(backbone_path, "views", plural_name, "#{singular_name}_view.js.coffee")
    template "templates-sp/model.jst", File.join(backbone_path, "templates", plural_name, "#{singular_name}.jst.ejs")
  else
    available_views.each do |view|
      template "views/#{view}_view.coffee", File.join(backbone_path, "views", plural_name, "#{view}_view.js.coffee")
      template "templates/#{view}.jst", File.join(backbone_path, "templates", plural_name, "#{view}.jst.ejs")       
    end
    
    template "views/model_view.coffee", File.join(backbone_path, "views", plural_name, "#{singular_name}_view.js.coffee")
    template "templates/model.jst", File.join(backbone_path, "templates", plural_name, "#{singular_name}.jst.ejs")
  end
end