From 71b50e820960eeb7073cc9494f4a8ec5d743fa64 Mon Sep 17 00:00:00 2001 From: Felipe Vogel Date: Sat, 22 Jan 2022 08:49:27 -0500 Subject: [PATCH] Map Stimulus controller filenames to identifiers as in the Stimulus docs --- .../lib/bridgetown-core/configurations/stimulus.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bridgetown-core/lib/bridgetown-core/configurations/stimulus.rb b/bridgetown-core/lib/bridgetown-core/configurations/stimulus.rb index 053f73d36..67442628e 100644 --- a/bridgetown-core/lib/bridgetown-core/configurations/stimulus.rb +++ b/bridgetown-core/lib/bridgetown-core/configurations/stimulus.rb @@ -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)