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 +4 -4
- data/docs/CHANGELOG.md +10 -0
- data/lib/view_component/base.rb +3 -2
- data/lib/view_component/collection.rb +12 -2
- data/lib/view_component/version.rb +1 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84bc019145d592e5a7f4dbb439cc960497ac347e12c2a6f73d7544a777365522
|
4
|
+
data.tar.gz: 2832c147430779d124335b8e82c915115b5b6840ab02365df551f5313621e85c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
data/lib/view_component/base.rb
CHANGED
@@ -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
|
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.
|
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-
|
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: []
|