Sha256: e772b70e6e2ff72df9da54b57bf6cbebc1033b9ab8e43e508c4ca010339e8fed

Contents?: true

Size: 492 Bytes

Versions: 9

Compression:

Stored size: 492 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(/\//, "--")
    end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
stimulus-rails-0.7.0 lib/generators/stimulus/stimulus_generator.rb
stimulus-rails-0.6.2 lib/generators/stimulus/stimulus_generator.rb
stimulus-rails-0.6.1 lib/generators/stimulus/stimulus_generator.rb
stimulus-rails-0.6.0 lib/generators/stimulus/stimulus_generator.rb
stimulus-rails-0.5.4 lib/generators/stimulus/stimulus_generator.rb
stimulus-rails-0.5.3 lib/generators/stimulus/stimulus_generator.rb
stimulus-rails-0.5.2 lib/generators/stimulus/stimulus_generator.rb
stimulus-rails-0.5.1 lib/generators/stimulus/stimulus_generator.rb
stimulus-rails-0.5.0 lib/generators/stimulus/stimulus_generator.rb