@@ -12,7 +12,7 @@ def digest
1212 gather_templates
1313 @templates . map do |template |
1414 if template . type == :file
15- template_string = template . send ( : source)
15+ template_string = template . source
1616 ViewComponent ::TemplateDependencyExtractor . new ( template_string , template . extension . to_sym ) . extract
1717 else
1818 # A digest cant be built for inline calls as there is no template to parse
@@ -22,64 +22,7 @@ def digest
2222 end
2323
2424 def gather_templates
25- @templates ||=
26- begin
27- templates = @component . sidecar_files (
28- ActionView ::Template . template_handler_extensions
29- ) . map do |path |
30- # Extract format and variant from template filename
31- this_format , variant =
32- File
33- . basename ( path ) # "variants_component.html+mini.watch.erb"
34- . split ( "." ) [ 1 ..-2 ] # ["html+mini", "watch"]
35- . join ( "." ) # "html+mini.watch"
36- . split ( "+" ) # ["html", "mini.watch"]
37- . map ( &:to_sym ) # [:html, :"mini.watch"]
38-
39- out = Template . new (
40- component : @component ,
41- type : :file ,
42- path : path ,
43- lineno : 0 ,
44- extension : path . split ( "." ) . last ,
45- this_format : this_format . to_s . split ( "." ) . last &.to_sym , # strip locale from this_format, see #2113
46- variant : variant
47- )
48-
49- out
50- end
51-
52- component_instance_methods_on_self = @component . instance_methods ( false )
53-
54- (
55- @component . ancestors . take_while { |ancestor | ancestor != ViewComponent ::Base } - @component . included_modules
56- ) . flat_map { |ancestor | ancestor . instance_methods ( false ) . grep ( /^call(_|$)/ ) }
57- . uniq
58- . each do |method_name |
59- templates << Template . new (
60- component : @component ,
61- type : :inline_call ,
62- this_format : ViewComponent ::Base ::VC_INTERNAL_DEFAULT_FORMAT ,
63- variant : method_name . to_s . include? ( "call_" ) ? method_name . to_s . sub ( "call_" , "" ) . to_sym : nil ,
64- method_name : method_name ,
65- defined_on_self : component_instance_methods_on_self . include? ( method_name )
66- )
67- end
68-
69- if @component . inline_template . present?
70- templates << Template . new (
71- component : @component ,
72- type : :inline ,
73- path : @component . inline_template . path ,
74- lineno : @component . inline_template . lineno ,
75- source : @component . inline_template . source . dup ,
76- extension : @component . inline_template . language
77- )
78- end
79-
80- templates
81- end
25+ @templates = @component . compiler . send ( :gather_templates )
8226 end
83-
8427 end
8528end
0 commit comments