view_component 2.76.0 → 2.77.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c17ad11c023d788b67aab113d0f09522d73606a41078742b81c0f807ea35aa23
4
- data.tar.gz: 8d1c75623f80627af69d1cae1859d42b02c21729b45524516a6e76ad8ca63892
3
+ metadata.gz: fb24cfba68b7323e80beee43cfb7a676ddc833bc87d63201d953d16301defe5d
4
+ data.tar.gz: 40599c33c49d1dcaa29ae1ec0b6b9e93f191735c2e28207d88717f3f9c77a561
5
5
  SHA512:
6
- metadata.gz: 57192b2d9de4714b4ee3ca786e169c02ad654fe7dda69b3e538c1d1f115eff7738326c64d0edbaf78efbb84356a9a5248a940fa0d311c033968a62afc276c76d
7
- data.tar.gz: 6bac50c320935e1cf1fd17a0ce2d846c1aedc40b63ed9c081a0010f04c5696b1b9b92938997a581df4876c846dbcc3fe2d08e1fc17a593d03842168423e878a6
6
+ metadata.gz: b6dd24af9a10eae0a9fc81c18570fe410686bad3db5cbb9840ee0f52038185eff956c64d260b9231d75226ae7e06a7fcdcafcbc4c37214917bf7155b64d2dc59
7
+ data.tar.gz: 863f21e3be9102ddc02b6a20a7c804b4b1490c7714fbbf2ea848b79a3b5da6cec960afa28fe7bb752e882da6cb4df89a4db67a7d462dfaaf40261b8b2bbf64d1
data/docs/CHANGELOG.md CHANGED
@@ -10,6 +10,12 @@ nav_order: 5
10
10
 
11
11
  ## main
12
12
 
13
+ ## 2.77.0
14
+
15
+ * Support variants with dashes in their names.
16
+
17
+ *Javi Martín*
18
+
13
19
  ## 2.76.0
14
20
 
15
21
  * `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 == :#{variant}\n #{call_method_name(variant)}"
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
@@ -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("-", "__")
258
+ end
259
+
243
260
  def should_compile_superclass?
244
261
  development? &&
245
262
  templates.empty? &&
@@ -3,7 +3,7 @@
3
3
  module ViewComponent
4
4
  module VERSION
5
5
  MAJOR = 2
6
- MINOR = 76
6
+ MINOR = 77
7
7
  PATCH = 0
8
8
 
9
9
  STRING = [MAJOR, MINOR, PATCH].join(".")
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.76.0
4
+ version: 2.77.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-16 00:00:00.000000000 Z
11
+ date: 2022-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport