Sha256: 9e8bc668ec8b51244dde3f5aed581f03c8a732fac8ce6c1fa2aa294bdf254848
Contents?: true
Size: 776 Bytes
Versions: 7
Compression:
Stored size: 776 Bytes
Contents
require "rails/generators/named_base" class StimulusGenerator < Rails::Generators::NamedBase # :nodoc: source_root File.expand_path("templates", __dir__) class_option :skip_manifest, type: :boolean, default: false, desc: "Don't update the stimulus manifest" def copy_view_files @attribute = stimulus_attribute_value(controller_name) template "controller.js", "app/javascript/controllers/#{controller_name}_controller.js" rails_command "stimulus:manifest:update" unless Rails.root.join("config/importmap.rb").exist? || options[:skip_manifest] end private def controller_name name.underscore.gsub(/_controller$/, "") end def stimulus_attribute_value(controller_name) controller_name.gsub(/\//, "--").gsub("_", "-") end end
Version data entries
7 entries across 7 versions & 2 rubygems