stimulus_tag_helper 0.2.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/lib/stimulus_tag_helper/stimulus_controller_builder.rb +21 -4
- data/lib/stimulus_tag_helper/version.rb +1 -1
- data/lib/stimulus_tag_helper.rb +5 -11
- 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: 1078cddfbd535e267d08882379327c0c4d19d57257fdea47cce3694daca9c2db
|
4
|
+
data.tar.gz: 33e92a8572f01e606014f24d1834b9fbad415ba631058160d454baf73f677f94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9deb8c164aad97521e0f2db8ee6d3ae66f3b8918c4b566d377aea038b44606817646ec8f242c0c5d8072b592bd5969fec3195e01d3d5ececaa5077c1c224776a
|
7
|
+
data.tar.gz: ead6ee7e15df412012a062ffc9ac1c5c3d0b1b60be4a0cd5e1576d60177390df3823d8f30d04e420d9589b8e476fa33f34601c8797bdd09a05f13de3dc044582
|
data/LICENSE.txt
CHANGED
@@ -6,9 +6,14 @@ module StimulusTagHelper
|
|
6
6
|
delegate :properties, :aliases, :attribute_method_name_for, :property_method_name_for, to: StimulusTagHelper
|
7
7
|
end
|
8
8
|
|
9
|
-
|
9
|
+
attr_reader :identifier, :template, :tag, :tag_options
|
10
|
+
|
11
|
+
# all the options are tag options of now
|
12
|
+
def initialize(identifier:, template:, tag: nil, **tag_options)
|
10
13
|
@identifier = identifier
|
11
14
|
@template = template
|
15
|
+
@tag = tag
|
16
|
+
@tag_options = tag_options
|
12
17
|
end
|
13
18
|
|
14
19
|
properties.each do |name|
|
@@ -18,7 +23,7 @@ module StimulusTagHelper
|
|
18
23
|
|
19
24
|
class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
|
20
25
|
def #{name}(*args, **kwargs) # def values(*args, **kwargs)
|
21
|
-
|
26
|
+
template.stimulus_#{attribute_method_name}(*args.unshift(identifier), **kwargs) # template.stimulus_values_attributes(*args.unshift(identifier), **kwargs)
|
22
27
|
end # end
|
23
28
|
|
24
29
|
alias_method :#{alias_name}, :#{name} # alias_method :value, :values
|
@@ -26,7 +31,7 @@ module StimulusTagHelper
|
|
26
31
|
alias_method :#{alias_name}_attribute, :#{name} # alias_method :value_attribute, :values
|
27
32
|
|
28
33
|
def #{property_method_name}(*args, **kwargs) # def values_properties(*args, **kwargs)
|
29
|
-
|
34
|
+
template.stimulus_#{property_method_name}(*args.unshift(identifier), **kwargs) # template.stimulus_values_properties(*args.unshift(identifier), **kwargs)
|
30
35
|
end # end
|
31
36
|
|
32
37
|
alias_method :#{alias_name}_property, :#{property_method_name} # alias_method :value_property, :values_properties
|
@@ -34,7 +39,19 @@ module StimulusTagHelper
|
|
34
39
|
end
|
35
40
|
|
36
41
|
def attributes(**attributes)
|
37
|
-
|
42
|
+
template.stimulus_attributes(identifier, **attributes)
|
43
|
+
end
|
44
|
+
|
45
|
+
def properties(**properties)
|
46
|
+
template.stimulus_properties(identifier, **properties)
|
47
|
+
end
|
48
|
+
|
49
|
+
def capture(&block)
|
50
|
+
return template.capture(self, &block) unless tag
|
51
|
+
|
52
|
+
template.stimulus_controller_tag(identifier, tag: tag, **tag_options) do
|
53
|
+
template.capture(self, &block)
|
54
|
+
end
|
38
55
|
end
|
39
56
|
end
|
40
57
|
end
|
data/lib/stimulus_tag_helper.rb
CHANGED
@@ -44,16 +44,10 @@ module StimulusTagHelper
|
|
44
44
|
STRING
|
45
45
|
end
|
46
46
|
|
47
|
-
def stimulus_controller(identifier, tag: nil, **
|
48
|
-
|
49
|
-
|
50
|
-
builder
|
51
|
-
|
52
|
-
return capture(builder, &block) unless tag
|
53
|
-
|
54
|
-
stimulus_controller_tag(identifier, tag: tag, **args) do
|
55
|
-
capture(builder, &block)
|
56
|
-
end
|
47
|
+
def stimulus_controller(identifier, tag: nil, **options, &block)
|
48
|
+
builder = StimulusControllerBuilder.new(identifier: identifier, tag: tag, template: self, **options)
|
49
|
+
return builder unless block
|
50
|
+
builder.capture(&block)
|
57
51
|
end
|
58
52
|
|
59
53
|
# controller arg is used to add additional stimulus controllers to the element
|
@@ -93,7 +87,7 @@ module StimulusTagHelper
|
|
93
87
|
end
|
94
88
|
|
95
89
|
def stimulus_controllers_attribute(...)
|
96
|
-
{data:
|
90
|
+
{data: stimulus_controllers_property(...)}
|
97
91
|
end
|
98
92
|
|
99
93
|
alias_method :stimulus_controller_attribute, :stimulus_controllers_attribute
|
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.2
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Topchii
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|