Class: Activoate::ActivoatedGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Activoate::ActivoatedGenerator
- Defined in:
- lib/generators/activoate/activoated/activoated_generator.rb
Instance Method Summary collapse
- #copy_views ⇒ Object
-
#initialize(args, *options) ⇒ ActivoatedGenerator
constructor
A new instance of ActivoatedGenerator.
Constructor Details
#initialize(args, *options) ⇒ ActivoatedGenerator
Returns a new instance of ActivoatedGenerator.
20 21 22 23 |
# File 'lib/generators/activoate/activoated/activoated_generator.rb', line 20 def initialize(args, *) super(args, *) initialize_views_variables end |
Instance Method Details
#copy_views ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/generators/activoate/activoated/activoated_generator.rb', line 25 def copy_views generate_views unless .layout.blank? if .engine =~ /erb/ gsub_file(File.join('app/views/layouts', "#{[:layout]}.html.#{.engine}"), /\<div\s+id=\"main-navigation\">.*\<\/ul\>/mi) do |match| match.gsub!(/\<\/ul\>/, "") %|#{match} <li class="<%= controller.controller_path == '#{@controller_file_path}' ? 'active' : '' %>"><a href="<%= #{controller_routing_path}_path %>">#{plural_model_name}</a></li></ul>| end elsif .engine =~ /haml/ gsub_file(File.join('app/views/layouts', "#{[:layout]}.html.#{.engine}"), /#main-navigation.*#wrapper.wat-cf/mi) do |match| match.gsub!(/ #wrapper.wat-cf/, "") %|#{match}| + " "*6 + %|%li{:class => controller.controller_path == '#{@controller_file_path}' ? 'active' : '' }\n| + " "*7 + %|%a{:href => #{controller_routing_path}_path} #{plural_model_name}\n| + " "*3 + %|#wrapper.wat-cf| end end end end |