view_component 2.50.0 → 2.51.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 +18 -0
- data/lib/view_component/base.rb +12 -4
- data/lib/view_component/compile_cache.rb +2 -1
- data/lib/view_component/compiler.rb +12 -9
- 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: 163414625d8e2df6f2afddc821a6c849aef71cc8cd1ba458a533d90840e545cc
|
4
|
+
data.tar.gz: 3518269c96d4e62d3bcedae22871c7b260d2abf42e0c1e32703115185e69eeea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 531785b833a4d1a83b6929095b6a6a34076cb6576820884487a247d70c37bde2fedc47914633674c59a888dc7270526660e121f4980f2bcb85625ed6009607c4
|
7
|
+
data.tar.gz: e4c8b2694c7f70c529d56dcced18f66d511e909e1f36abc604a58402d1332caecde59d40c065668454af8abf6d53578469539ac1f4366650ad286856b50776fa
|
data/docs/CHANGELOG.md
CHANGED
@@ -7,6 +7,24 @@ title: Changelog
|
|
7
7
|
|
8
8
|
## main
|
9
9
|
|
10
|
+
## 2.51.0
|
11
|
+
|
12
|
+
* Update the docs only when releasing a new version.
|
13
|
+
|
14
|
+
*Hans Lemuet*
|
15
|
+
|
16
|
+
* Alphabetize companies using ViewComponent and add Brightline to the list.
|
17
|
+
|
18
|
+
*Jack Schuss*
|
19
|
+
|
20
|
+
* Add CMYK value for ViewComponent Red color on logo page.
|
21
|
+
|
22
|
+
*Dylan Smith*
|
23
|
+
|
24
|
+
* Improve performance by moving template compilation from `#render_in` to `#render_template_for`.
|
25
|
+
|
26
|
+
*Cameron Dutro*
|
27
|
+
|
10
28
|
## 2.50.0
|
11
29
|
|
12
30
|
* Add tests for `layout` usage when rendering via controller.
|
data/lib/view_component/base.rb
CHANGED
@@ -66,8 +66,6 @@ module ViewComponent
|
|
66
66
|
#
|
67
67
|
# @return [String]
|
68
68
|
def render_in(view_context, &block)
|
69
|
-
self.class.compile(raise_errors: true)
|
70
|
-
|
71
69
|
@view_context = view_context
|
72
70
|
self.__vc_original_view_context ||= view_context
|
73
71
|
|
@@ -112,6 +110,16 @@ module ViewComponent
|
|
112
110
|
@current_template = old_current_template
|
113
111
|
end
|
114
112
|
|
113
|
+
# :nocov:
|
114
|
+
def render_template_for(variant = nil)
|
115
|
+
# Force compilation here so the compiler always redefines render_template_for.
|
116
|
+
# This is mostly a safeguard to prevent infinite recursion.
|
117
|
+
self.class.compile(raise_errors: true, force: true)
|
118
|
+
# .compile replaces this method; call the new one
|
119
|
+
render_template_for(variant)
|
120
|
+
end
|
121
|
+
# :nocov:
|
122
|
+
|
115
123
|
# EXPERIMENTAL: Optional content to be returned after the rendered template.
|
116
124
|
#
|
117
125
|
# @return [String]
|
@@ -445,8 +453,8 @@ module ViewComponent
|
|
445
453
|
# Do as much work as possible in this step, as doing so reduces the amount
|
446
454
|
# of work done each time a component is rendered.
|
447
455
|
# @private
|
448
|
-
def compile(raise_errors: false)
|
449
|
-
compiler.compile(raise_errors: raise_errors)
|
456
|
+
def compile(raise_errors: false, force: false)
|
457
|
+
compiler.compile(raise_errors: raise_errors, force: force)
|
450
458
|
end
|
451
459
|
|
452
460
|
# @private
|
@@ -27,12 +27,11 @@ module ViewComponent
|
|
27
27
|
self.class.mode == DEVELOPMENT_MODE
|
28
28
|
end
|
29
29
|
|
30
|
-
def compile(raise_errors: false)
|
31
|
-
return if compiled?
|
30
|
+
def compile(raise_errors: false, force: false)
|
31
|
+
return if compiled? && !force
|
32
|
+
return if component_class == ViewComponent::Base
|
32
33
|
|
33
34
|
with_lock do
|
34
|
-
CompileCache.invalidate_class!(component_class)
|
35
|
-
|
36
35
|
subclass_instance_methods = component_class.instance_methods(false)
|
37
36
|
|
38
37
|
if subclass_instance_methods.include?(:with_content) && raise_errors
|
@@ -65,8 +64,8 @@ module ViewComponent
|
|
65
64
|
# as Ruby warns when redefining a method.
|
66
65
|
method_name = call_method_name(template[:variant])
|
67
66
|
|
68
|
-
if component_class.instance_methods.include?(method_name.to_sym)
|
69
|
-
component_class.send(:
|
67
|
+
if component_class.instance_methods(false).include?(method_name.to_sym)
|
68
|
+
component_class.send(:remove_method, method_name.to_sym)
|
70
69
|
end
|
71
70
|
|
72
71
|
component_class.class_eval <<-RUBY, template[:path], -1
|
@@ -93,14 +92,18 @@ module ViewComponent
|
|
93
92
|
end
|
94
93
|
end
|
95
94
|
|
95
|
+
def reset_render_template_for
|
96
|
+
if component_class.instance_methods(false).include?(:render_template_for)
|
97
|
+
component_class.send(:remove_method, :render_template_for)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
96
101
|
private
|
97
102
|
|
98
103
|
attr_reader :component_class
|
99
104
|
|
100
105
|
def define_render_template_for
|
101
|
-
|
102
|
-
component_class.send(:undef_method, :render_template_for)
|
103
|
-
end
|
106
|
+
reset_render_template_for
|
104
107
|
|
105
108
|
variant_elsifs = variants.compact.uniq.map do |variant|
|
106
109
|
"elsif variant.to_sym == :#{variant}\n #{call_method_name(variant)}"
|
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.51.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub Open Source
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|