Class: Mustache::Generators::ControllerGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Extended by:
TemplatePath
Defined in:
lib/generators/mustache/controller/controller_generator.rb

Instance Method Summary collapse

Methods included from TemplatePath

source_root

Instance Method Details

#create_view_filesObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/generators/mustache/controller/controller_generator.rb', line 11

def create_view_files
  model_path                  = File.join(class_path, file_name)
  
  base_mustache_view_path     = File.join("app/views", model_path)
  empty_directory base_mustache_view_path
  
  base_mustache_template_path = File.join("app/templates", model_path)
  empty_directory base_mustache_template_path
  
  actions.each do |action|
    @action  = action
    mustache_view_path       = File.join(base_mustache_view_path,
                                          "#{action}.rb")
    mustache_template_path   = File.join(base_mustache_template_path,
                                          "#{action}.html.mustache")
    
    template "view.rb.erb", mustache_view_path
    template "view.html.mustache.erb", mustache_template_path                                   
  end
end