@@ -24,6 +24,13 @@ class Base < ActionView::Base
24
24
class_attribute :slots
25
25
self . slots = { }
26
26
27
+ class_attribute :vc_lookup_context
28
+ self . vc_lookup_context = ActionView ::LookupContext . new ( ActionView ::PathSet . new ( [ Rails . root . join ( "app/components" ) ] ) , { } , [ ] )
29
+
30
+ # For rails 5.2 and older
31
+ class_attribute :vc_view_renderer
32
+ @view_renderer = ActionView ::Renderer . new ( vc_lookup_context )
33
+
27
34
# Entrypoint for rendering components.
28
35
#
29
36
# view_context: ActionView context from calling view
@@ -52,9 +59,8 @@ def render_in(view_context, &block)
52
59
self . class . compile ( raise_errors : true )
53
60
54
61
@view_context = view_context
55
- @lookup_context ||= view_context . lookup_context . tap do |c |
56
- c . view_paths . unshift ( Rails . root . join ( "app/components" ) )
57
- end
62
+ @lookup_context = vc_lookup_context
63
+ @view_renderer = vc_view_renderer
58
64
59
65
# required for path helpers in older Rails versions
60
66
@view_renderer ||= view_context . view_renderer
@@ -66,7 +72,7 @@ def render_in(view_context, &block)
66
72
@virtual_path ||= virtual_path
67
73
68
74
# For template variants (+phone, +desktop, etc.)
69
- @variant ||= @ lookup_context. variants . first
75
+ @variant ||= view_context . lookup_context . variants . first
70
76
71
77
# For caching, such as #cache_if
72
78
@current_template = nil unless defined? ( @current_template )
0 commit comments