diff --git a/lib/action_view/component/base.rb b/lib/action_view/component/base.rb index 2eccca1c5..cdb785e47 100644 --- a/lib/action_view/component/base.rb +++ b/lib/action_view/component/base.rb @@ -117,19 +117,19 @@ def template_file_path filename = self.instance_method(:initialize).source_location[0] filename_without_extension = filename[0..-(File.extname(filename).length + 1)] - sibling_files = Dir["#{filename_without_extension}.*"] - [filename] + sibling_template_files = Dir["#{filename_without_extension}.????.{#{ActionView::Template.template_handler_extensions.join(',')}}"] - [filename] - if sibling_files.length > 1 + if sibling_template_files.length > 1 raise StandardError.new("More than one template found for #{self}. There can only be one sidecar template file per component.") end - if sibling_files.length == 0 + if sibling_template_files.length == 0 raise NotImplementedError.new( "Could not find a template file for #{self}." ) end - sibling_files[0] + sibling_template_files[0] end end diff --git a/test/action_view/component_test.rb b/test/action_view/component_test.rb index 67372afb8..15454f4ab 100644 --- a/test/action_view/component_test.rb +++ b/test/action_view/component_test.rb @@ -130,6 +130,12 @@ def test_renders_another_component assert_equal trim_result(result.css("div").first.to_html), "