view_component 2.23.1 → 2.23.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of view_component might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/view_component/collection.rb +8 -5
- data/lib/view_component/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae234d64ddfd0c5c6943d58cad1c5ae034c036cd3663680fdbfa01dbb7c0bb26
|
4
|
+
data.tar.gz: 66ee3f2c510d649be7f4b4bb1ce99d63daa546fd738c70bd19edabe011c5f237
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60101dbc8eee7be6fdbedd45bd414a6788e1e3d734f5126a6f3afb6ebcffb11b131bd5d04aece9eb1d45f3dec99067d2038f7313894031e501773e995b5f77c6
|
7
|
+
data.tar.gz: b6351313799ac1e85b0668270669677e1646c7d410b0ac14c3fb807a21a8cc53538dfb71934da2cb8a4fe60ef3db1f8edbb06e1651600a8bea4adb66c4d0bfa1
|
data/CHANGELOG.md
CHANGED
@@ -4,14 +4,17 @@ require "action_view/renderer/collection_renderer" if Rails.version.to_f >= 6.1
|
|
4
4
|
|
5
5
|
module ViewComponent
|
6
6
|
class Collection
|
7
|
+
attr_reader :component
|
8
|
+
delegate :format, to: :component
|
9
|
+
|
7
10
|
def render_in(view_context, &block)
|
8
11
|
iterator = ActionView::PartialIteration.new(@collection.size)
|
9
12
|
|
10
|
-
|
11
|
-
|
13
|
+
component.compile(raise_errors: true)
|
14
|
+
component.validate_collection_parameter!(validate_default: true)
|
12
15
|
|
13
16
|
@collection.map do |item|
|
14
|
-
content =
|
17
|
+
content = component.new(**component_options(item, iterator)).render_in(view_context, &block)
|
15
18
|
iterator.iterate!
|
16
19
|
content
|
17
20
|
end.join.html_safe
|
@@ -34,8 +37,8 @@ module ViewComponent
|
|
34
37
|
end
|
35
38
|
|
36
39
|
def component_options(item, iterator)
|
37
|
-
item_options = {
|
38
|
-
item_options[
|
40
|
+
item_options = { component.collection_parameter => item }
|
41
|
+
item_options[component.collection_counter_parameter] = iterator.index + 1 if component.counter_argument_present?
|
39
42
|
|
40
43
|
@options.merge(item_options)
|
41
44
|
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: 2.23.
|
4
|
+
version: 2.23.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub Open Source
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -198,7 +198,7 @@ dependencies:
|
|
198
198
|
- - "~>"
|
199
199
|
- !ruby/object:Gem::Version
|
200
200
|
version: '0.13'
|
201
|
-
description:
|
201
|
+
description:
|
202
202
|
email:
|
203
203
|
- opensource+view_component@github.com
|
204
204
|
executables: []
|
@@ -253,7 +253,7 @@ licenses:
|
|
253
253
|
- MIT
|
254
254
|
metadata:
|
255
255
|
allowed_push_host: https://rubygems.org
|
256
|
-
post_install_message:
|
256
|
+
post_install_message:
|
257
257
|
rdoc_options: []
|
258
258
|
require_paths:
|
259
259
|
- lib
|
@@ -269,7 +269,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
269
269
|
version: '0'
|
270
270
|
requirements: []
|
271
271
|
rubygems_version: 3.1.2
|
272
|
-
signing_key:
|
272
|
+
signing_key:
|
273
273
|
specification_version: 4
|
274
274
|
summary: View components for Rails
|
275
275
|
test_files: []
|