view_component 2.76.0 → 2.78.0
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/docs/CHANGELOG.md +12 -0
- data/lib/view_component/compiler.rb +20 -3
- data/lib/view_component/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fbd11387f1d91c630d91d12ce292fe85f3ac95063d32cb5fef898012f098dc8
|
4
|
+
data.tar.gz: a54372810de68fdfe4d863437ace9a4ab9f930e4255c16d1b696053ecaae2c96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a702c2c57c6763340ae79be1eb454c4d451601eb8c7007257318bfe87bd88710e53c5875e7308440008c9c32b55038d6691d58217f6f1c5390e4b643b0c91f11
|
7
|
+
data.tar.gz: 0d38198fe331e12a2d2b250888980d09d059dc6f1d5a392e5646ee3c834f71fb856cfd8cd4b9eaf02ce6facec836aa849fcb18af95f6239a0dc1396c96d7faf4
|
data/docs/CHANGELOG.md
CHANGED
@@ -10,6 +10,18 @@ nav_order: 5
|
|
10
10
|
|
11
11
|
## main
|
12
12
|
|
13
|
+
## 2.78.0
|
14
|
+
|
15
|
+
* Support variants with dots in their names.
|
16
|
+
|
17
|
+
*Javi Martín*
|
18
|
+
|
19
|
+
## 2.77.0
|
20
|
+
|
21
|
+
* Support variants with dashes in their names.
|
22
|
+
|
23
|
+
*Javi Martín*
|
24
|
+
|
13
25
|
## 2.76.0
|
14
26
|
|
15
27
|
* `Component.with_collection` supports components that accept splatted keyword arguments.
|
@@ -92,7 +92,7 @@ module ViewComponent
|
|
92
92
|
|
93
93
|
def define_render_template_for
|
94
94
|
variant_elsifs = variants.compact.uniq.map do |variant|
|
95
|
-
"elsif variant.to_sym ==
|
95
|
+
"elsif variant.to_sym == :'#{variant}'\n #{call_method_name(variant)}"
|
96
96
|
end.join("\n")
|
97
97
|
|
98
98
|
body = <<-RUBY
|
@@ -163,6 +163,19 @@ module ViewComponent
|
|
163
163
|
"There can only be a template file or inline render method per variant."
|
164
164
|
end
|
165
165
|
|
166
|
+
uniq_variants = variants.compact.uniq
|
167
|
+
normalized_variants = uniq_variants.map { |variant| normalized_variant_name(variant) }
|
168
|
+
|
169
|
+
colliding_variants = uniq_variants.select do |variant|
|
170
|
+
normalized_variants.count(normalized_variant_name(variant)) > 1
|
171
|
+
end
|
172
|
+
|
173
|
+
unless colliding_variants.empty?
|
174
|
+
errors <<
|
175
|
+
"Colliding templates #{colliding_variants.sort.map { |v| "'#{v}'" }.to_sentence} " \
|
176
|
+
"found in #{component_class}."
|
177
|
+
end
|
178
|
+
|
166
179
|
errors
|
167
180
|
end
|
168
181
|
end
|
@@ -176,7 +189,7 @@ module ViewComponent
|
|
176
189
|
pieces = File.basename(path).split(".")
|
177
190
|
memo << {
|
178
191
|
path: path,
|
179
|
-
variant: pieces.
|
192
|
+
variant: pieces[1..-2].join(".").split("+").second&.to_sym,
|
180
193
|
handler: pieces.last
|
181
194
|
}
|
182
195
|
end
|
@@ -234,12 +247,16 @@ module ViewComponent
|
|
234
247
|
|
235
248
|
def call_method_name(variant)
|
236
249
|
if variant.present? && variants.include?(variant)
|
237
|
-
"call_#{variant}"
|
250
|
+
"call_#{normalized_variant_name(variant)}"
|
238
251
|
else
|
239
252
|
"call"
|
240
253
|
end
|
241
254
|
end
|
242
255
|
|
256
|
+
def normalized_variant_name(variant)
|
257
|
+
variant.to_s.gsub("-", "__").gsub(".", "___")
|
258
|
+
end
|
259
|
+
|
243
260
|
def should_compile_superclass?
|
244
261
|
development? &&
|
245
262
|
templates.empty? &&
|
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.
|
4
|
+
version: 2.78.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: 2022-11-
|
11
|
+
date: 2022-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|