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

Open
mrrooijen opened this Issue Dec 11, 2010 · 1 comment

Comments

Projects
None yet
2 participants
Contributor

mrrooijen commented Dec 11, 2010

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. : )

Contributor

ogeidix commented Dec 28, 2010

Fixed in version 0.6.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment