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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 999b55cbd4ceffe9c68cce73f072542ca117191cf8d816e4453f5da3c0373e3d
4
- data.tar.gz: a9ccac5daddbf14cf5bf472ef17288da765b80d35c83d695d4972a40cf77fa95
3
+ metadata.gz: 1078cddfbd535e267d08882379327c0c4d19d57257fdea47cce3694daca9c2db
4
+ data.tar.gz: 33e92a8572f01e606014f24d1834b9fbad415ba631058160d454baf73f677f94
5
5
  SHA512:
6
- metadata.gz: feb8293ffa622314a26e8a54237770768c126316e0f5558d44968abf9b7e209cca7aabba79c5de48971d0423dc68d3387f49716240d0c570768c89485461eb9e
7
- data.tar.gz: d4cc16a147a1d9b1943b15bedf9ca2b75cd2057b0fa5e18794fbd8e191820c31d59e085675b536ed8e33f9071562f8459cc641fe226a7987155b9e1171e5c5f5
6
+ metadata.gz: 9deb8c164aad97521e0f2db8ee6d3ae66f3b8918c4b566d377aea038b44606817646ec8f242c0c5d8072b592bd5969fec3195e01d3d5ececaa5077c1c224776a
7
+ data.tar.gz: ead6ee7e15df412012a062ffc9ac1c5c3d0b1b60be4a0cd5e1576d60177390df3823d8f30d04e420d9589b8e476fa33f34601c8797bdd09a05f13de3dc044582
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2021 Anton Topchii
3
+ Copyright (c) 2022 Anton Topchii
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -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.2"
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
@@ -93,7 +87,7 @@ module StimulusTagHelper
93
87
  end
94
88
 
95
89
  def stimulus_controllers_attribute(...)
96
- {data: stimulus_controllers_properties(...)}
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.1
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-14 00:00:00.000000000 Z
11
+ date: 2022-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails