Sha256: 110d1c832a7432848937419e95074b124b450298ee33644320eadcfa6807f4e5
Contents?: true
Size: 642 Bytes
Versions: 7
Compression:
Stored size: 642 Bytes
Contents
require "rails/generators/named_base" class StimulusGenerator < Rails::Generators::NamedBase # :nodoc: source_root File.expand_path("templates", __dir__) 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? 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 & 1 rubygems