stimulus-rails 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +7 -7
- data/lib/install/stimulus.rb +9 -2
- data/lib/stimulus-rails.rb +3 -3
- data/lib/stimulus/engine.rb +2 -3
- 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: 9315f38125eef25637dac7d0a752284aae1774ff9a201b4ba1053b7e4be5883e
|
4
|
+
data.tar.gz: 142e1f79541405565ee24ccf6d6db31d6f6271e0c34b29938cfcdaba5d3a6dd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d5eb9560d3b69c4f3b467b022ea7fab69fe5b1963bb1ecc2db06a047fe1e07f5e609e2f88b1cf1e723eb1d57a910a6ccf0eb0693d731dde467d89a97180f816
|
7
|
+
data.tar.gz: 0d9cce5a56e595d947455cd69367b13c514cbaa658ab6dbea783d60ceb7ff961c136b8fe79bc785b4e1744f7a17d66f439337360bda26c7b34738b765160f710
|
data/README.md
CHANGED
@@ -14,17 +14,17 @@ If you want to use Stimulus with a bundler, you should use [Webpacker](https://g
|
|
14
14
|
|
15
15
|
The last command will:
|
16
16
|
|
17
|
-
1. Create an example controller in app/assets/javascripts/controllers/hello_controller.js
|
18
|
-
2. Append the include tags to the `<head>` of your application.html.erb
|
19
|
-
3. Initialize your importmap.json in app/assets/javascripts/importmap.json.erb
|
20
|
-
4. Ensure JavaScript is included in your app/config/manifest.js file for compilation.
|
17
|
+
1. Create an example controller in `app/assets/javascripts/controllers/hello_controller.js`
|
18
|
+
2. Append the include tags to the `<head>` of your `app/views/layouts/application.html.erb`.
|
19
|
+
3. Initialize your `importmap.json` in `app/assets/javascripts/importmap.json.erb`.
|
20
|
+
4. Ensure JavaScript is included in your `app/config/manifest.js` file for compilation.
|
21
21
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
25
|
With the Stimulus include tags added, you'll automatically have activated Stimulus through the controller autoloader. You can now easily add new Stimulus controllers that'll be loaded via ESM dynamic imports.
|
26
26
|
|
27
|
-
For example, a more advanced hello_controller could look like this:
|
27
|
+
For example, a more advanced `hello_controller` could look like this:
|
28
28
|
|
29
29
|
```javascript
|
30
30
|
// app/assets/javascripts/controllers/hello_controller.js
|
@@ -43,13 +43,13 @@ And it'll be activated and registered automatically when encountering the data-c
|
|
43
43
|
|
44
44
|
```html
|
45
45
|
<div data-controller="hello">
|
46
|
-
<input data-target="
|
46
|
+
<input data-hello-target="name" type="text">
|
47
47
|
|
48
48
|
<button data-action="click->hello#greet">
|
49
49
|
Greet
|
50
50
|
</button>
|
51
51
|
|
52
|
-
<span data-target="
|
52
|
+
<span data-hello-target="output">
|
53
53
|
</span>
|
54
54
|
</div>
|
55
55
|
```
|
data/lib/install/stimulus.rb
CHANGED
@@ -5,8 +5,15 @@ empty_directory "app/assets/javascripts/libraries"
|
|
5
5
|
say "Add app/javascripts to asset pipeline manifest"
|
6
6
|
append_to_file Rails.root.join("app/assets/config/manifest.js").to_s, "//= link_tree ../javascripts\n"
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
APPLICATION_LAYOUT_PATH = Rails.root.join("app/views/layouts/application.html.erb")
|
9
|
+
|
10
|
+
if APPLICATION_LAYOUT_PATH.exist?
|
11
|
+
say "Add Stimulus include tags in application layout"
|
12
|
+
insert_into_file Rails.root.join("app/views/layouts/application.html.erb").to_s, "\n <%= stimulus_include_tags %>", before: /\s*<\/head>/
|
13
|
+
else
|
14
|
+
say "Default application.html.erb is missing!", :red
|
15
|
+
say " Add <%= stimulus_include_tags %> within the <head> tag in your custom layout."
|
16
|
+
end
|
10
17
|
|
11
18
|
say "Turn off development debug mode"
|
12
19
|
comment_lines Rails.root.join("config/environments/development.rb"), /config.assets.debug = true/
|
data/lib/stimulus-rails.rb
CHANGED
data/lib/stimulus/engine.rb
CHANGED
@@ -2,8 +2,7 @@ require "stimulus/importmap_helper"
|
|
2
2
|
|
3
3
|
module Stimulus
|
4
4
|
class Engine < ::Rails::Engine
|
5
|
-
|
6
|
-
config.eager_load_namespaces << Stimulus
|
5
|
+
config.autoload_once_paths = %w( #{root}/app/helpers )
|
7
6
|
|
8
7
|
initializer "stimulus.assets" do
|
9
8
|
Rails.application.config.assets.precompile += %w( importmap.json stimulus/manifest )
|
@@ -11,7 +10,7 @@ module Stimulus
|
|
11
10
|
|
12
11
|
initializer "stimulus.helpers" do
|
13
12
|
ActiveSupport.on_load(:action_controller_base) do
|
14
|
-
helper Stimulus::
|
13
|
+
helper Stimulus::StimulusHelper
|
15
14
|
end
|
16
15
|
|
17
16
|
Rails.application.config.assets.configure do |env|
|
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.1.
|
4
|
+
version: 0.1.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: 2020-12-
|
13
|
+
date: 2020-12-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|