Class: NgOnRails::ViewsGenerator
Instance Method Summary
collapse
#set_attributes, source_root
Instance Method Details
#add_css ⇒ Object
69
70
71
72
73
74
75
76
77
|
# File 'lib/generators/ng_on_rails/views_generator.rb', line 69
def add_css
if options[:styles]
styles_path = "app/assets/stylesheets/ng_on_rails_styles.css"
unless File.exist?(styles_path)
puts "Adding ng_on_rails_styles.css -- <better with bootstrap and fontAwesome!>"
copy_file "#{ViewsGenerator.source_root}/styles_template.css", styles_path
end
end
end
|
#create_jbuilder_files ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/generators/ng_on_rails/views_generator.rb', line 42
def create_jbuilder_files
if options[:render_views] || options[:rails_views]
unless File.exist?(index_path)
puts "File[ #{index_path} ] does not exist. creating file"
create_file index_path, '/ File created with NgOnRails view generator'
end
unless File.exist?(show_path)
puts "File[ #{show_path} ] does not exist. creating file"
create_file show_path, '/ File created with NgOnRails view generator'
end
end
end
|
#create_render_views_files ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/generators/ng_on_rails/views_generator.rb', line 28
def create_render_views_files
if options[:render_views] || options[:rails_views]
unless File.exist?(index_path)
puts "File[ #{index_path} ] does not exist. creating file"
create_file index_path, '/ File created with NgOnRails view generator'
end
unless File.exist?(show_path)
puts "File[ #{show_path} ] does not exist. creating file"
create_file show_path, '/ File created with NgOnRails view generator'
end
end
end
|
#generate_jbuilder_files ⇒ Object
63
64
65
66
67
|
# File 'lib/generators/ng_on_rails/views_generator.rb', line 63
def generate_jbuilder_files
if options[:jbuilder] || options[:rails_views]
generate "ng_on_rails:jbuilder #{full_model_name} #{jbuilder_attributes} --overwrite=#{options[:overwrite]}"
end
end
|
#generate_views ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/generators/ng_on_rails/views_generator.rb', line 10
def generate_views
option_template "#{ViewsGenerator.source_root}/views/#{options[:format]}/index.html.erb",
"app/views/#{module_path}angular_app/#{plural_name}/index.html.#{options[:format]}",
"index view"
option_template "#{ViewsGenerator.source_root}/views/#{options[:format]}/show.html.erb",
"app/views/#{module_path}angular_app/#{plural_name}/show.html.#{options[:format]}",
"show view"
option_template "#{ViewsGenerator.source_root}/views/#{options[:format]}/_show.html.erb",
"app/views/#{module_path}angular_app/#{plural_name}/_show.html.#{options[:format]}",
"_show partial"
option_template "#{ViewsGenerator.source_root}/views/#{options[:format]}/_form.html.erb",
"app/views/#{module_path}angular_app/#{plural_name}/_form.html.#{options[:format]}",
"_form partial"
option_template "#{ViewsGenerator.source_root}/views/#{options[:format]}/_model.html.erb",
"app/views/#{module_path}angular_app/#{plural_name}/_#{resource_name}.html.#{options[:format]}",
"_#{resource_name} partial"
end
|
#insert_render_views ⇒ Object
56
57
58
59
60
61
|
# File 'lib/generators/ng_on_rails/views_generator.rb', line 56
def insert_render_views
if options[:render_views] || options[:rails_views]
append_file index_path, render_index_view_template
append_file show_path, render_show_view_template
end
end
|