diff options
author | Nicholas La Roux <larouxn@gmail.com> | 2019-04-04 16:21:04 +0900 |
---|---|---|
committer | Nicholas La Roux <larouxn@gmail.com> | 2019-04-05 16:09:22 +0900 |
commit | d442d97bfa9b0dd8bdab731b29afe404e3b724de (patch) | |
tree | 2ef0477b5cf544b6af8a098b7cb0f6b37d37d859 /railties/lib | |
parent | bd1e9a1b98d1a3fcd419e4f975f7efa012b6f399 (diff) | |
download | rails-d442d97bfa9b0dd8bdab731b29afe404e3b724de.tar.gz rails-d442d97bfa9b0dd8bdab731b29afe404e3b724de.tar.bz2 rails-d442d97bfa9b0dd8bdab731b29afe404e3b724de.zip |
Resurrect js/js engine options and generators
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/generators.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/generators/js/assets/assets_generator.rb | 15 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/assets/assets_generator.rb | 7 |
3 files changed, 24 insertions, 0 deletions
diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb index b835b3f3fd..0be00d5151 100644 --- a/railties/lib/rails/generators.rb +++ b/railties/lib/rails/generators.rb @@ -35,6 +35,8 @@ module Rails rails: { actions: "-a", orm: "-o", + javascripts: "-j", + javascript_engine: "-je", resource_controller: "-c", scaffold_controller: "-c", stylesheets: "-y", diff --git a/railties/lib/rails/generators/js/assets/assets_generator.rb b/railties/lib/rails/generators/js/assets/assets_generator.rb new file mode 100644 index 0000000000..31a443838c --- /dev/null +++ b/railties/lib/rails/generators/js/assets/assets_generator.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + + require "rails/generators/named_base" + + module Js # :nodoc: + module Generators # :nodoc: + class AssetsGenerator < Rails::Generators::NamedBase # :nodoc: + source_root File.expand_path("templates", __dir__) + + def copy_javascript + copy_file "javascript.js", File.join("app/javascript", class_path, "#{file_name}.js") + end + end + end +end diff --git a/railties/lib/rails/generators/rails/assets/assets_generator.rb b/railties/lib/rails/generators/rails/assets/assets_generator.rb index 9ce8570172..e60637ff37 100644 --- a/railties/lib/rails/generators/rails/assets/assets_generator.rb +++ b/railties/lib/rails/generators/rails/assets/assets_generator.rb @@ -3,7 +3,10 @@ module Rails module Generators class AssetsGenerator < NamedBase # :nodoc: + class_option :javascripts, type: :boolean, desc: "Generate JavaScripts" class_option :stylesheets, type: :boolean, desc: "Generate Stylesheets" + + class_option :javascript_engine, desc: "Engine for JavaScripts" class_option :stylesheet_engine, desc: "Engine for Stylesheets" private @@ -11,6 +14,10 @@ module Rails file_name end + hook_for :javascript_engine do |javascript_engine| + invoke javascript_engine, [name] if options[:javascripts] + end + hook_for :stylesheet_engine do |stylesheet_engine| invoke stylesheet_engine, [name] if options[:stylesheets] end |