view_component 3.19.0 → 3.20.0

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: ab3409edb096d7b91d8b88fbcbc7570b130ec8c06ecebcaa1432088ed75b3493
4
- data.tar.gz: d9fd6e36e4321916c631b80f221b38ab122e619856621109b8a0cc6e6d383a0b
3
+ metadata.gz: 84bc019145d592e5a7f4dbb439cc960497ac347e12c2a6f73d7544a777365522
4
+ data.tar.gz: 2832c147430779d124335b8e82c915115b5b6840ab02365df551f5313621e85c
5
5
  SHA512:
6
- metadata.gz: c850104905f0f99a90366a794aefba1f6dfddbf8e319708830baadaf97a0d0d368a7dcfc69b15024226939959a1368c2a8f533360aa0992810d76e17d4b9ef67
7
- data.tar.gz: 3693e06fab4c1cc45659cfefa9187ef329b0486c186f26779c3ff086365822d2de8a396f6932071756762187cb972f36ac53eab7583b938722958ba1bf7df2c9
6
+ metadata.gz: ccbe1677fec16d8de063aafe220ada3ee0647d9963d91f269ef3081b9b2edffc4bf2f535c2097a730d72e80521a9367e97353927997f353f3ec59923e2611deb
7
+ data.tar.gz: d52f357464701228bc686f4ea367974a287ce4fcd895845814f9a175635750664b705411c096f3f01c0bad0914a1db95573f50d12ff1b0e7d9029a55adf492b8
data/docs/CHANGELOG.md CHANGED
@@ -10,6 +10,16 @@ nav_order: 5
10
10
 
11
11
  ## main
12
12
 
13
+ ## 3.20.0
14
+
15
+ * Allow rendering `with_collection` to accept an optional `spacer_component` to be rendered between each item.
16
+
17
+ *Nick Coyne*
18
+
19
+ * Remove OpenStruct from codebase.
20
+
21
+ *Oleksii Vasyliev*
22
+
13
23
  ## 3.19.0
14
24
 
15
25
  * Relax Active Support version constraint in gemspec.
@@ -509,9 +509,10 @@ module ViewComponent
509
509
  # ```
510
510
  #
511
511
  # @param collection [Enumerable] A list of items to pass the ViewComponent one at a time.
512
+ # @param spacer_component [ViewComponent::Base] Component instance to be rendered between items.
512
513
  # @param args [Arguments] Arguments to pass to the ViewComponent every time.
513
- def with_collection(collection, **args)
514
- Collection.new(self, collection, **args)
514
+ def with_collection(collection, spacer_component: nil, **args)
515
+ Collection.new(self, collection, spacer_component, **args)
515
516
  end
516
517
 
517
518
  # @private
@@ -19,7 +19,7 @@ module ViewComponent
19
19
  components.map do |component|
20
20
  component.set_original_view_context(__vc_original_view_context)
21
21
  component.render_in(view_context, &block)
22
- end.join.html_safe
22
+ end.join(rendered_spacer(view_context)).html_safe
23
23
  end
24
24
 
25
25
  def components
@@ -48,9 +48,10 @@ module ViewComponent
48
48
 
49
49
  private
50
50
 
51
- def initialize(component, object, **options)
51
+ def initialize(component, object, spacer_component, **options)
52
52
  @component = component
53
53
  @collection = collection_variable(object || [])
54
+ @spacer_component = spacer_component
54
55
  @options = options
55
56
  end
56
57
 
@@ -69,5 +70,14 @@ module ViewComponent
69
70
 
70
71
  @options.merge(item_options)
71
72
  end
73
+
74
+ def rendered_spacer(view_context)
75
+ if @spacer_component
76
+ @spacer_component.set_original_view_context(__vc_original_view_context)
77
+ @spacer_component.render_in(view_context)
78
+ else
79
+ ""
80
+ end
81
+ end
72
82
  end
73
83
  end
@@ -3,7 +3,7 @@
3
3
  module ViewComponent
4
4
  module VERSION
5
5
  MAJOR = 3
6
- MINOR = 19
6
+ MINOR = 20
7
7
  PATCH = 0
8
8
  PRE = nil
9
9
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: view_component
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.19.0
4
+ version: 3.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ViewComponent Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-22 00:00:00.000000000 Z
11
+ date: 2024-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -548,20 +548,6 @@ dependencies:
548
548
  - - ">="
549
549
  - !ruby/object:Gem::Version
550
550
  version: '0'
551
- - !ruby/object:Gem::Dependency
552
- name: ostruct
553
- requirement: !ruby/object:Gem::Requirement
554
- requirements:
555
- - - ">="
556
- - !ruby/object:Gem::Version
557
- version: '0'
558
- type: :development
559
- prerelease: false
560
- version_requirements: !ruby/object:Gem::Requirement
561
- requirements:
562
- - - ">="
563
- - !ruby/object:Gem::Version
564
- version: '0'
565
551
  description:
566
552
  email:
567
553
  executables: []