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:
parent
bd1e9a1b98
commit
d442d97bfa
3 changed files with 24 additions and 0 deletions
|
@ -35,6 +35,8 @@ module Rails
|
|||
rails: {
|
||||
actions: "-a",
|
||||
orm: "-o",
|
||||
javascripts: "-j",
|
||||
javascript_engine: "-je",
|
||||
resource_controller: "-c",
|
||||
scaffold_controller: "-c",
|
||||
stylesheets: "-y",
|
||||
|
|
15
railties/lib/rails/generators/js/assets/assets_generator.rb
Normal file
15
railties/lib/rails/generators/js/assets/assets_generator.rb
Normal 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
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue