Sha256: db8e06ca55a7bedd8ff31b2e7c606cbefae86646f042b76677d59f3f270cc756

Contents?: true

Size: 507 Bytes

Versions: 3

Compression:

Stored size: 507 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(name)
    template "controller.js", "app/javascript/controllers/#{name}_controller.js"
    rails_command "stimulus:manifest:update" if Rails.root.join("package.json").exist?
  end

  private
    def stimulus_attribute_value(name)
      name.gsub(/\//, "--").gsub("_", "-")
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
stimulus-rails-0.7.3 lib/generators/stimulus/stimulus_generator.rb
stimulus-rails-0.7.2 lib/generators/stimulus/stimulus_generator.rb
stimulus-rails-0.7.1 lib/generators/stimulus/stimulus_generator.rb