Class: AppThemer::ViewsGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- AppThemer::ViewsGenerator
- Defined in:
- lib/generators/app_themer/views/views_generator.rb
Instance Method Summary collapse
- #copy_views ⇒ Object
-
#initialize(args, *options) ⇒ ViewsGenerator
constructor
A new instance of ViewsGenerator.
Constructor Details
#initialize(args, *options) ⇒ ViewsGenerator
Returns a new instance of ViewsGenerator.
15 16 17 18 |
# File 'lib/generators/app_themer/views/views_generator.rb', line 15 def initialize(args, *) super(args, *) initialize_views_variables end |
Instance Method Details
#copy_views ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/generators/app_themer/views/views_generator.rb', line 20 def copy_views generate_views unless .layout.blank? gsub_file(File.join('app/views/layouts', "#{options[:layout]}.html.#{options.engine}"), /\<nav\s+id=\"main-navigation\">.*\<\/ul\>/mi) do |match| match.gsub!(/\<\/ul\>/, "") if @engine.to_s =~ /haml/ %|#{match} %li{:class => controller.controller_path == '#{@controller_file_path}' ? 'active' : '' } %a{:href => #{controller_routing_path}_path} #{plural_model_name} </ul>| else %|#{match} <li class="<%= controller.controller_path == '#{@controller_file_path}' ? 'active' : '' %>"><a href="<%= #{controller_routing_path}_path %>">#{plural_model_name}</a></li></ul>| end end end end |