stimulus-rails 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/app/assets/javascripts/stimulus-importmap-autoloader.js +1 -1
- data/lib/stimulus/manifest.rb +11 -7
- data/lib/stimulus/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55f2f78c04bb5e5e457a008c8be807c29ed61c6192f75633643b8f9b2cbda516
|
4
|
+
data.tar.gz: b03050a3322e99eab6d85006feb1b0190ab70d9c8715e410ad868f65d75947af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f281e3eb9e2f3e8c31d2097b557e116151390e54a7c5f1b5e333770514be4bf0ebb2794011bad1e6a163e661c56e903c7b7344fed49430471cb48f87b1f1173
|
7
|
+
data.tar.gz: 10d351b7e2f7e37ede5641ad9d049953405fb981217673e65aa7f734338e5f3aa0f67720e529a425673f379e81da8fcb493e92dd5fdbc3a53fb9b082c8fb67a3
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[Stimulus](https://stimulus.hotwired.dev) is a JavaScript framework with modest ambitions. It doesn’t seek to take over your entire front-end in fact, it’s not concerned with rendering HTML at all. Instead, it’s designed to augment your HTML with just enough behavior to make it shine. Stimulus pairs beautifully with Turbo to provide a complete solution for fast, compelling applications with a minimal amount of effort. Together they form the core of [Hotwire](https://hotwired.dev).
|
4
4
|
|
5
|
-
Stimulus for Rails makes it easy to use this modest framework with the asset pipeline and ES6/ESM in the browser. It relies on `importmap-rails` to make
|
5
|
+
Stimulus for Rails makes it easy to use this modest framework with the asset pipeline and ES6/ESM in the browser. It relies on either `importmap-rails` to make Stimulus available via ESM or a node-capable Rails (like via `jsbundling-rails`) to include Stimulus in the bundle. Make sure to install one of these first!
|
6
6
|
|
7
7
|
|
8
8
|
## Installation
|
@@ -11,7 +11,7 @@ Stimulus for Rails makes it easy to use this modest framework with the asset pip
|
|
11
11
|
2. Run `./bin/bundle install`.
|
12
12
|
3. Run `./bin/rails stimulus:install`
|
13
13
|
|
14
|
-
The installer will automatically detect whether you're using an [import map](https://github.com/rails/importmap-rails) or [JavaScript bundler](https://github.com/rails/jsbundling-rails) to manage your application's JavaScript. If you're using an import map, the Stimulus dependencies will be pinned to the versions of the library included with this gem. If you're using node, yarn will add the dependencies to your package.json file.
|
14
|
+
The installer will automatically detect whether you're using an [import map](https://github.com/rails/importmap-rails) or [JavaScript bundler](https://github.com/rails/jsbundling-rails) to manage your application's JavaScript. If you're using an import map, the Stimulus dependencies will be pinned to the versions of the library included with this gem. If you're using node, yarn will add the dependencies to your `package.json` file.
|
15
15
|
|
16
16
|
|
17
17
|
## Usage
|
@@ -14,7 +14,7 @@ export function parseImportmapJson() {
|
|
14
14
|
|
15
15
|
function registerControllerFromPath(path, under, application) {
|
16
16
|
const name = path
|
17
|
-
.replace(
|
17
|
+
.replace(new RegExp(`^${under}/`), "")
|
18
18
|
.replace("_controller", "")
|
19
19
|
.replace(/\//g, "--")
|
20
20
|
.replace(/_/g, "-")
|
data/lib/stimulus/manifest.rb
CHANGED
@@ -3,16 +3,20 @@ module Stimulus::Manifest
|
|
3
3
|
|
4
4
|
def generate_from(controllers_path)
|
5
5
|
extract_controllers_from(controllers_path).collect do |controller_path|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
import_and_register_controller(controllers_path, controller_path)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def import_and_register_controller(controllers_path, controller_path)
|
11
|
+
module_path = controller_path.relative_path_from(controllers_path).to_s.remove(".js")
|
12
|
+
controller_class_name = module_path.camelize.gsub(/::/, "__")
|
13
|
+
tag_name = module_path.remove("_controller").gsub(/_/, "-").gsub(/\//, "--")
|
14
|
+
|
15
|
+
<<-JS
|
11
16
|
|
12
17
|
import #{controller_class_name} from "./#{module_path}"
|
13
18
|
application.register("#{tag_name}", #{controller_class_name})
|
14
|
-
|
15
|
-
end
|
19
|
+
JS
|
16
20
|
end
|
17
21
|
|
18
22
|
def extract_controllers_from(directory)
|
data/lib/stimulus/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stimulus-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Stephenson
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-09-
|
13
|
+
date: 2021-09-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|