Skip to content
Browse files

Fixed the item addition to main navigation menu with haml engine

  • Loading branch information...
1 parent 1d03176 commit bd8db0a2ab4d4efcbbadec20ffff21984906f808 @ogeidix ogeidix committed Dec 27, 2010
Showing with 11 additions and 8 deletions.
  1. +11 −8 lib/generators/web_app_theme/themed/themed_generator.rb
View
19 lib/generators/web_app_theme/themed/themed_generator.rb
@@ -20,16 +20,19 @@ def initialize(args, *options)
def copy_views
generate_views
unless options.layout.blank?
- gsub_file(File.join('app/views/layouts', "#{options[:layout]}.html.#{options.engine}"), /\<div\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
+ 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

0 comments on commit bd8db0a

Please sign in to comment.
Something went wrong with that request. Please try again.