stimulizer 0.2.0 → 0.2.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/CHANGELOG.md +4 -0
- data/README.md +15 -0
- data/lib/stimulizer/version.rb +1 -1
- data/lib/stimulizer.rb +6 -7
- 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: ede79e02bdfb78d4042f27f862c167c67284704c4b198bb6a0782517ebf5f779
|
4
|
+
data.tar.gz: b62f26675aa4724f34912b16817ced4f49894b799a548fa104efaf2d42deaa8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b1df244a9281ccf7afceef04e2be0ac128da7098f67b65788a000334752f52a7204eb6609a3e4571bf927b008364653b5bb0ce53eb1b0be9f44e09ada4206e4
|
7
|
+
data.tar.gz: 2cdd6844616929b08d1947ada11cec929d14b32b894a8299b5ae39bf7a8cb9cebc6510d59404cd9f6f37fbbfd7215ab4407fc8b1f3960000e49a5bc02303f8f3
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -49,6 +49,18 @@ Or install it yourself as:
|
|
49
49
|
$ gem install stimulizer
|
50
50
|
|
51
51
|
## Usage
|
52
|
+
### in a classic ERB View
|
53
|
+
Include the module in your ApplicationController (or individual controllers):
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
class ApplicationController < ActionController::Base
|
57
|
+
include Stimulizer
|
58
|
+
helper_method :stimulus
|
59
|
+
# ...
|
60
|
+
```
|
61
|
+
NOTE that you have to add `helper_method :stimulus` to ensure the view templates can use the `stimulus` method.
|
62
|
+
|
63
|
+
### in a ViewComponent
|
52
64
|
Include this in your class:
|
53
65
|
|
54
66
|
```ruby
|
@@ -88,6 +100,9 @@ Render the stimulusjs data strings into your template...
|
|
88
100
|
|
89
101
|
<!-- supports the 'params' feature -->
|
90
102
|
<%= stimulus(params: {foo: "bar", this_thing: "whatever"})
|
103
|
+
|
104
|
+
<!-- supports the 'outlets' feature -->
|
105
|
+
<%= stimulus(outlets: {foo: ".my-class", bar: "#widget"})
|
91
106
|
```
|
92
107
|
... or combine them:
|
93
108
|
```
|
data/lib/stimulizer/version.rb
CHANGED
data/lib/stimulizer.rb
CHANGED
@@ -49,13 +49,12 @@ module Stimulizer
|
|
49
49
|
output = stimulus_hash(*args)
|
50
50
|
return output if _stimulizer_opts[:output] == :hash
|
51
51
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
)
|
52
|
+
output.to_a
|
53
|
+
.map { |k, v| %(#{k.to_s.strip}="#{v.to_s.strip}") }
|
54
|
+
.join(" ")
|
55
|
+
.squish
|
56
|
+
.strip
|
57
|
+
.html_safe
|
59
58
|
end
|
60
59
|
|
61
60
|
private
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stimulizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt E Patterson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-configurable
|