]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Improve rails generator
authorNick Kugaevsky <nick@kugaevsky.ru>
Sun, 10 Mar 2013 02:40:57 +0000 (06:40 +0400)
committerNick Kugaevsky <nick@kugaevsky.ru>
Sun, 10 Mar 2013 02:40:57 +0000 (06:40 +0400)
  - fixed usage text
  - choose layout template depending of installed engines

lib/foundation/generators/USAGE
lib/foundation/generators/install_generator.rb

index d0dc8fefc86ed564c0d6b67d14526516d383139d..3b7893bef2c60812466adaa10935a729e466f84a 100644 (file)
@@ -1,14 +1,15 @@
 Description:
-    Setup Foundation assets on your website or generate new layouts preconfigured to use Foundation
+    Setup Foundation assets in your app and generate new layouts preconfigured to use Foundation
 
 Example:
   rails g foundation:install
 
-  This will replace the default application assets:
+  This will insert foundation require lines into default application assets:
     /app/assets/javascripts/application.js
     /app/assets/stylesheets/application.css
 
-  rails generate foundation:layout
-
-  This will create:
+  And create sample layout (depending of your template engine):
     /app/views/layouts/application.html.erb
+
+  And foundation variables override file:
+    /app/assets/stylesheets/foundation_and_overrides.scss
index 0a73dc43b0a4adfddb6fc9f4f5531ee79f9ebcac..d08ea2dff4ee24ae8c98e33a4423e4a13d839b2a 100644 (file)
@@ -6,9 +6,9 @@ module Foundation
       source_root File.join(File.dirname(__FILE__), 'templates')
       argument :layout_name, :type => :string, :default => 'application', :banner => 'layout_name'
 
-      class_option :haml, :desc => 'Generate HAML layout instead of ERB.', :type => :boolean
-      class_option :slim, :desc => 'Generate Slim layout instead of ERB.', :type => :boolean
-      
+      class_option :haml, :desc => 'Generate HAML layout instead of erb', :type => :boolean
+      class_option :slim, :desc => 'Generate Slim layout instead of erb', :type => :boolean
+
       def add_assets
         # rails_ujs breaks, need to incorporate rails-behavior plugin for this to work seamlessly
         # gsub_file "app/assets/javascripts/application#{detect_js_format[0]}", /\/\/= require jquery\n/, ""
@@ -17,14 +17,14 @@ module Foundation
         settings_file = File.join(File.dirname(__FILE__),"..","..","..","templates","project","scss","_settings.scss")
         create_file "app/assets/stylesheets/foundation_and_overrides.scss", File.read(settings_file)
         append_to_file "app/assets/stylesheets/foundation_and_overrides.scss", "\n@import 'foundation';\n"
-        insert_into_file "app/assets/stylesheets/application#{detect_css_format[0]}", "#{detect_css_format[1]} require foundation_and_overrides\n", :after => "require_self\n" 
+        insert_into_file "app/assets/stylesheets/application#{detect_css_format[0]}", "#{detect_css_format[1]} require foundation_and_overrides\n", :after => "require_self\n"
       end
-      
+
       def detect_js_format
         return ['.js.coffee', '#='] if File.exist?('app/assets/javascripts/application.js.coffee')
         return ['.js', '//='] if File.exist?('app/assets/javascripts/application.js')
       end
-      
+
       def detect_css_format
         return ['.css', ' *='] if File.exist?('app/assets/stylesheets/application.css')
         return ['.css.sass', ' //='] if File.exist?('app/assets/stylesheets/application.css.sass')
@@ -34,9 +34,9 @@ module Foundation
       end
 
       def create_layout
-        if options.haml?
+        if options.haml?||(defined?(Haml) && !options.slim?)
           template 'application.html.haml', "app/views/layouts/#{file_name}.html.haml"
-        elsif options.slim?
+        elsif options.slim?||(defined?(Slim) && !options.haml?)
           template 'application.html.slim', "app/views/layouts/#{file_name}.html.slim"
         else
           template 'application.html.erb', "app/views/layouts/#{file_name}.html.erb"
@@ -50,4 +50,4 @@ module Foundation
       end
     end
   end
-end
\ No newline at end of file
+end