Skip to content

Commit

Permalink
Map Stimulus controller filenames to identifiers as in the Stimulus d…
Browse files Browse the repository at this point in the history
…ocs (#486)
  • Loading branch information
fpsvogel authored Jan 24, 2022
1 parent dd9a2e0 commit c4108f0
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@
import controllers from "./controllers/**/*.{js,js.rb}"
Object.entries(controllers).forEach(([filename, controller]) => {
if (filename.includes("_controller.")) {
if (filename.includes("_controller.") || filename.includes("-controller.")) {
const identifier = filename.replace("./controllers/", "")
.replace(/_controller\..*$/, "")
.replace(/[_\-]controller\..*$/, "")
.replace("_", "-")
.replace("/", "--")
Stimulus.register(identifier, controller.default)
Expand Down

0 comments on commit c4108f0

Please sign in to comment.