Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for dasherized controller filenames #126

Merged
merged 1 commit into from Jan 3, 2024

Conversation

adrienpoly
Copy link
Member

Summary

This PR extends the current functionality of the Gem to support Stimulus controllers with dasherized names (multi-word-dash_controller.js), in addition to the existing camel_case support (multi_word_controller.js).

Background

The Gem currently supports only Stimulus controllers with names in camel_case.
Dasherized names is part of the Stimulus documentation https://stimulus.hotwired.dev/reference/controllers#identifiers

Given that the controller name written in the DOM is using dash to me it feels more natural to write it like that in my filename.

Changes

This PR adds support for dasherized controller names and includes a corresponding test case. With these changes, the Gem will support the following naming structures:

├── coffee_controller.coffee
├── hello_controller.js
├── multi-word-dash_controller.js
├── multi_word_underscore_controller.js
├── namespace
│   ├── multi-word-dash_controller.js
│   ├── multi_word_underscore_controller.js
│   └── namespaced_controller.js
└── type_script_controller.ts

Copy link
Member

@marcoroth marcoroth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes sense!

This also aligns with the behavior of the @hotwired/stimulus-webpack-helper npm package

@dhh dhh merged commit bf50ed5 into hotwired:main Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants