class ViewComponent::Preview

def preview_example_template_path(example)

Returns the relative path (from preview_path) to the preview example template if the template exists
def preview_example_template_path(example)
  preview_path =
    Array(preview_paths).detect do |path|
      Dir["#{path}/#{preview_name}_preview/#{example}.html.*"].first
    end
  raise MissingPreviewTemplateError.new(example) if preview_path.nil?
  path = Dir["#{preview_path}/#{preview_name}_preview/#{example}.html.*"].first
  Pathname.new(path)
    .relative_path_from(Pathname.new(preview_path))
    .to_s
    .sub(/\..*$/, "")
end