Class: SkeletonLoader::TemplatePathFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/skeleton_loader/template_path_finder.rb

Overview

This class is responsible for locating a specific template file by type. It searches through configured paths and defaults to searching in ‘app/views/skeleton_loader` within the Rails root directory. Raises an error if the template is not found.

Class Method Summary collapse

Class Method Details

.find(type) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/skeleton_loader/template_path_finder.rb', line 11

def self.find(type)
  template_name = "_#{type}.html.erb"
  search_paths = SkeletonLoader.configuration.template_paths +
                 [Rails.root.join("app/views/skeleton_loader")]

  search_paths.each do |path|
    full_path = File.join(path, template_name)
    return full_path if File.exist?(full_path)
  end

  raise "Template '#{template_name}' not found in any of the specified paths."
end