Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Open
meskyanichi opened this Issue · 1 comment

2 participants

@meskyanichi
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

Fixed in version 0.6.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.