stimulus_tag_helper 0.2.1 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 999b55cbd4ceffe9c68cce73f072542ca117191cf8d816e4453f5da3c0373e3d
4
- data.tar.gz: a9ccac5daddbf14cf5bf472ef17288da765b80d35c83d695d4972a40cf77fa95
3
+ metadata.gz: 1e14706b60764f1c964d28e6aee33ccbd1bd0ae37276f54551c2cef6382c3043
4
+ data.tar.gz: b2d6259c7ad45568e8b38fd2410a5cb4f7a2a2624d82fbd98ca9c1f638735f5f
5
5
  SHA512:
6
- metadata.gz: feb8293ffa622314a26e8a54237770768c126316e0f5558d44968abf9b7e209cca7aabba79c5de48971d0423dc68d3387f49716240d0c570768c89485461eb9e
7
- data.tar.gz: d4cc16a147a1d9b1943b15bedf9ca2b75cd2057b0fa5e18794fbd8e191820c31d59e085675b536ed8e33f9071562f8459cc641fe226a7987155b9e1171e5c5f5
6
+ metadata.gz: 30df03a48c9a2b28c8fdd84192c175756bcca535d14c4dc737b32e9afae027a8c95cbc110728e3a828466fe840894675e76937bdb24dedf57236017fc94a0b5e
7
+ data.tar.gz: 7270c3d1959724d3a481d805f0bdd87f4243f525c18ac01298b71fe7c89521453945e0d13d830afd71513b3a5fcbad6967750b6097ad5fa0dce19b264847792e
@@ -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
- def initialize(identifier:, template:)
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
- @template.stimulus_#{attribute_method_name}(*args.unshift(@identifier), **kwargs) # @template.stimulus_values_attributes(*args.unshift(@identifier), **kwargs)
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
- @template.stimulus_#{property_method_name}(*args.unshift(@identifier), **kwargs) # @template.stimulus_values_properties(*args.unshift(@identifier), **kwargs)
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
- @template.stimulus_attributes(@identifier, **attributes)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StimulusTagHelper
4
- VERSION = "0.2.1"
4
+ VERSION = "0.3.0"
5
5
  end
@@ -44,16 +44,10 @@ module StimulusTagHelper
44
44
  STRING
45
45
  end
46
46
 
47
- def stimulus_controller(identifier, tag: nil, **args, &block)
48
- raise(ArgumentError, "Missing block") unless block
49
-
50
- builder = StimulusControllerBuilder.new(identifier: identifier, template: self)
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
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.1
4
+ version: 0.3.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: 2022-07-14 00:00:00.000000000 Z
11
+ date: 2022-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails