1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Resurrect js/js engine options and generators

This commit is contained in:
Nicholas La Roux 2019-04-04 16:21:04 +09:00
parent bd1e9a1b98
commit d442d97bfa
No known key found for this signature in database
GPG key ID: EA5C7110ACC526A8
3 changed files with 24 additions and 0 deletions

View file

@ -35,6 +35,8 @@ module Rails
rails: {
actions: "-a",
orm: "-o",
javascripts: "-j",
javascript_engine: "-je",
resource_controller: "-c",
scaffold_controller: "-c",
stylesheets: "-y",

View file

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

View file

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