Class: KisoThemes::Generators::DashboardPagesGenerator

Inherits:
PageGenerator
  • Object
show all
Defined in:
lib/generators/kiso_themes/dashboard_pages_generator.rb

Instance Method Summary collapse

Methods inherited from PageGenerator

#copy_view, #create_controller, view_name

Instance Method Details

#copy_partialsObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/generators/kiso_themes/dashboard_pages_generator.rb', line 16

def copy_partials
  source_view_path="views/#{_view_type}/"
  partials = Dir.glob(File.expand_path("../templates/views/#{_view_type}/*", __FILE__)).select{ |lf| File.basename(lf).start_with?("_") && lf.end_with?(handler) }.map { |lf| File.basename(lf, ".html.#{handler}")}

  partials.each do |partial|
    destination = "app/views/#{name.underscore}/#{partial}.html.#{handler}"
    copy_file "views/#{_view_type}/#{partial}.html.#{handler}", destination
  end

  controller_const_name = "#{name.camelize}Controller"
  for action in actions do
    PageRewriter.compile("app/views/#{name.underscore}/#{action}.html.#{handler}", /dashboards/, "#{name.underscore}")
    inject_into_file "app/controllers/#{file_name}_controller.rb", after: "def #{action}"  do
  <<-RUBY
    \n    @body_class = "with-sidebar show-sidebar"
  RUBY
    end
  end
end

#set_layoutObject



11
12
13
14
# File 'lib/generators/kiso_themes/dashboard_pages_generator.rb', line 11

def set_layout
  controller_const_name = "#{name.camelize}Controller"
  inject_into_class File.join('app/controllers', class_path, "#{file_name}_controller.rb"), controller_const_name, "  layout 'sidenav'\n"
end