stimulus_tag_helper 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/stimulus_tag_helper/version.rb +1 -1
- data/lib/stimulus_tag_helper.rb +25 -6
- 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: d78596e159f3730ada65d162fd8cdf8cff63404bdb72f6770fb544e45693dd8d
|
4
|
+
data.tar.gz: 3bed5f63460088309fdb0d5f8448b415a31a86d0efe3b1a17e7b1cb7d354daa4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34ce331ca313d214394b301bf5017a469c8d64aa36464c73a1ac6fd580f5e488ca029631318c2cde54b34158284d6323c00ff1614f1e3f2cd690c3b0c1a7faf5
|
7
|
+
data.tar.gz: 20fa325fcae63d52d057143213eb707d362028fd54d0b5ee8bd6852d90407c398159b45139a008ac237695c498caa3fcb3b2aeedc9b6258705ff0200c45d50bf
|
data/lib/stimulus_tag_helper.rb
CHANGED
@@ -6,14 +6,17 @@ Zeitwerk::Loader.for_gem.setup
|
|
6
6
|
|
7
7
|
module StimulusTagHelper
|
8
8
|
def self.properties
|
9
|
-
%i[controllers values classes targets actions].freeze
|
9
|
+
%i[controllers values classes targets actions outlets].freeze
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.aliases
|
13
|
-
@aliases ||=
|
14
|
-
properties.
|
15
|
-
|
16
|
-
|
13
|
+
@aliases ||= {}.tap do |aliases|
|
14
|
+
properties.each do |property|
|
15
|
+
property_alias = property.to_s.singularize.to_sym
|
16
|
+
aliases[property] = property_alias
|
17
|
+
aliases[property_alias] = property
|
18
|
+
end
|
19
|
+
end.freeze
|
17
20
|
end
|
18
21
|
|
19
22
|
def self.all_possible_properties_names
|
@@ -31,7 +34,7 @@ module StimulusTagHelper
|
|
31
34
|
end
|
32
35
|
|
33
36
|
def self.rendered_as(property)
|
34
|
-
{controllers: :one, values: :many, classes: :many, targets: :many, actions: :one} \
|
37
|
+
{controllers: :one, values: :many, classes: :many, targets: :many, actions: :one, outlets: :many} \
|
35
38
|
[property] || raise(ArgumentError, "Unknown property: #{property.inspect}")
|
36
39
|
end
|
37
40
|
|
@@ -163,4 +166,20 @@ module StimulusTagHelper
|
|
163
166
|
# TODO: find a elegant way to escape -> splitter escaping > back and forth.
|
164
167
|
StimulusAction.new(identifier: identifier, **args_or_string).to_s.html_safe
|
165
168
|
end
|
169
|
+
|
170
|
+
def stimulus_outlets_attributes(...)
|
171
|
+
{data: stimulus_outlets_properties(...)}
|
172
|
+
end
|
173
|
+
|
174
|
+
alias_method :stimulus_outlet_attribute, :stimulus_outlets_attributes
|
175
|
+
|
176
|
+
def stimulus_outlets_properties(identifier, **outlets)
|
177
|
+
{}.tap do |properties|
|
178
|
+
outlets.each_pair do |name, selector|
|
179
|
+
properties["#{identifier}-#{name}-outlet"] = selector
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
alias_method :stimulus_outlet_property, :stimulus_outlets_properties
|
166
185
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stimulus_tag_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Topchii
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|