stimulus_tag_helper 0.3.2 → 0.4.1
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/lib/stimulus_tag_helper/version.rb +1 -1
- data/lib/stimulus_tag_helper.rb +31 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 884fa188e7ce8465fe8b7a33f0fd95f38c689dd33d548aecc23c83d6dd7e005a
|
4
|
+
data.tar.gz: 97cce9dbe7b99e3bd40a5f31d07691636d367d9cf7ee2d673bba8764209c3e46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abfcfb468f4f6ffe8436edcc2732fe565e0b402aedc8f3156a17f07f2b905f3cea091c7b3e24b389b0b1429b3916e7f533529dab3b582a6bd756afe03072c4ae
|
7
|
+
data.tar.gz: aac053f558ca00ae6cf6989581f74bf00f884c6847c95980cfcffdcb64eedafc33d794f5aa0a0bfc704ab5d18ac30bde186151f622cdc2b6b1b92702e3b55777
|
data/lib/stimulus_tag_helper.rb
CHANGED
@@ -5,15 +5,19 @@ require "zeitwerk"
|
|
5
5
|
Zeitwerk::Loader.for_gem.setup
|
6
6
|
|
7
7
|
module StimulusTagHelper
|
8
|
+
TAG_BUILDER_OPTIMIZED_VERION = Gem::Version.new("7.2.0")
|
8
9
|
def self.properties
|
9
|
-
%i[controllers values classes targets actions].freeze
|
10
|
+
%i[controllers values classes targets actions outlets].freeze
|
10
11
|
end
|
11
12
|
|
12
13
|
def self.aliases
|
13
|
-
@aliases ||=
|
14
|
-
properties.
|
15
|
-
|
16
|
-
|
14
|
+
@aliases ||= {}.tap do |aliases|
|
15
|
+
properties.each do |property|
|
16
|
+
property_alias = property.to_s.singularize.to_sym
|
17
|
+
aliases[property] = property_alias
|
18
|
+
aliases[property_alias] = property
|
19
|
+
end
|
20
|
+
end.freeze
|
17
21
|
end
|
18
22
|
|
19
23
|
def self.all_possible_properties_names
|
@@ -31,7 +35,7 @@ module StimulusTagHelper
|
|
31
35
|
end
|
32
36
|
|
33
37
|
def self.rendered_as(property)
|
34
|
-
{controllers: :one, values: :many, classes: :many, targets: :many, actions: :one} \
|
38
|
+
{controllers: :one, values: :many, classes: :many, targets: :many, actions: :one, outlets: :many} \
|
35
39
|
[property] || raise(ArgumentError, "Unknown property: #{property.inspect}")
|
36
40
|
end
|
37
41
|
|
@@ -61,7 +65,11 @@ module StimulusTagHelper
|
|
61
65
|
controller: data[:controller] || controller, # nil is allowed, because the args will be prepended by the identifier
|
62
66
|
**args.extract!(*StimulusTagHelper.all_possible_properties_names - %i[class])
|
63
67
|
))
|
64
|
-
|
68
|
+
if ActionView.version >= TAG_BUILDER_OPTIMIZED_VERION
|
69
|
+
tag_builder.tag_string(tag, nil, args.merge(data: data), &block)
|
70
|
+
else
|
71
|
+
tag_builder.tag_string(tag, **args.merge(data: data), &block)
|
72
|
+
end
|
65
73
|
end
|
66
74
|
|
67
75
|
def stimulus_attributes(...)
|
@@ -163,4 +171,20 @@ module StimulusTagHelper
|
|
163
171
|
# TODO: find a elegant way to escape -> splitter escaping > back and forth.
|
164
172
|
StimulusAction.new(identifier: identifier, **args_or_string).to_s.html_safe
|
165
173
|
end
|
174
|
+
|
175
|
+
def stimulus_outlets_attributes(...)
|
176
|
+
{data: stimulus_outlets_properties(...)}
|
177
|
+
end
|
178
|
+
|
179
|
+
alias_method :stimulus_outlet_attribute, :stimulus_outlets_attributes
|
180
|
+
|
181
|
+
def stimulus_outlets_properties(identifier, **outlets)
|
182
|
+
{}.tap do |properties|
|
183
|
+
outlets.each_pair do |name, selector|
|
184
|
+
properties["#{identifier}-#{name}-outlet"] = selector
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
alias_method :stimulus_outlet_property, :stimulus_outlets_properties
|
166
190
|
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.1
|
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: 2024-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
requirements: []
|
91
|
-
rubygems_version: 3.
|
91
|
+
rubygems_version: 3.5.21
|
92
92
|
signing_key:
|
93
93
|
specification_version: 4
|
94
94
|
summary: A form_for like, compact and elegant way to define stimulus attributes in
|