Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

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

mrrooijen opened this issue Dec 11, 2010 · 1 comment

Comments

@mrrooijen
Copy link
Contributor

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
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants