gravityblast / web-app-theme

A simple theme for web apps
Other
2.45k stars 387 forks source link

Themed generator doesn't add "layout" link with --engine=haml #18

Open mrrooijen opened 13 years ago

mrrooijen commented 13 years ago
rails g web_app_theme:themed admin/posts Post --layout=admin --engine=haml

Isn't working properly, it's just a small bug. When you run the above command it does create all the views properly, however, the --layout=admin doesn't add the "Posts" link in my navigation bar. It does do it when I use --engine=erb.

The problem I believe is somewhere in this block:

https://github.com/pilu/web-app-theme/blob/master/lib/generators/web_app_theme/themed/themed_generator.rb

# lib / generators / web_app_theme / themed / themed_generator.rb
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
        %|#{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

It probably cannot find the match and thus, ignores it completely. Do you see where this is failing? It's not a show stopper as I can just manually add them to the layout but it's a nice feature to have it do it for you. : )

ogeidix commented 13 years ago

Fixed in version 0.6.3