aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/generators/css
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/rails/generators/css')
-rw-r--r--railties/lib/rails/generators/css/assets/assets_generator.rb15
-rw-r--r--railties/lib/rails/generators/css/assets/templates/stylesheet.css4
-rw-r--r--railties/lib/rails/generators/css/scaffold/scaffold_generator.rb18
3 files changed, 37 insertions, 0 deletions
diff --git a/railties/lib/rails/generators/css/assets/assets_generator.rb b/railties/lib/rails/generators/css/assets/assets_generator.rb
new file mode 100644
index 0000000000..f657d1e50f
--- /dev/null
+++ b/railties/lib/rails/generators/css/assets/assets_generator.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+require "rails/generators/named_base"
+
+module Css # :nodoc:
+ module Generators # :nodoc:
+ class AssetsGenerator < Rails::Generators::NamedBase # :nodoc:
+ source_root File.expand_path("templates", __dir__)
+
+ def copy_stylesheet
+ copy_file "stylesheet.css", File.join("app/assets/stylesheets", class_path, "#{file_name}.css")
+ end
+ end
+ end
+end
diff --git a/railties/lib/rails/generators/css/assets/templates/stylesheet.css b/railties/lib/rails/generators/css/assets/templates/stylesheet.css
new file mode 100644
index 0000000000..afad32db02
--- /dev/null
+++ b/railties/lib/rails/generators/css/assets/templates/stylesheet.css
@@ -0,0 +1,4 @@
+/*
+ Place all the styles related to the matching controller here.
+ They will automatically be included in application.css.
+*/
diff --git a/railties/lib/rails/generators/css/scaffold/scaffold_generator.rb b/railties/lib/rails/generators/css/scaffold/scaffold_generator.rb
new file mode 100644
index 0000000000..89c560f382
--- /dev/null
+++ b/railties/lib/rails/generators/css/scaffold/scaffold_generator.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+require "rails/generators/named_base"
+
+module Css # :nodoc:
+ module Generators # :nodoc:
+ class ScaffoldGenerator < Rails::Generators::NamedBase # :nodoc:
+ source_root Rails::Generators::ScaffoldGenerator.source_root
+
+ # In order to allow the Sass generators to pick up the default Rails CSS and
+ # transform it, we leave it in a standard location for the CSS stylesheet
+ # generators to handle. For the simple, default case, just copy it over.
+ def copy_stylesheet
+ copy_file "scaffold.css", "app/assets/stylesheets/scaffold.css"
+ end
+ end
+ end
+end