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 options.layout.blank?
if options.engine =~ /erb/
gsub_file(File.join('app/views/layouts', "#{options[:layout]}.html.#{options.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 options.engine =~ /haml/
gsub_file(File.join('app/views/layouts', "#{options[:layout]}.html.#{options.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
|