Sha256: 494edfcbd2e1c992cd98148e92c426e380c4d8ce3a31c9456c7653a75d93604c
Contents?: true
Size: 631 Bytes
Versions: 1
Compression:
Stored size: 631 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" if Rails.root.join("package.json").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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stimulus-rails-1.0.0 | lib/generators/stimulus/stimulus_generator.rb |