class ViewComponent::Preview
def preview_example_template_path(example)
def preview_example_template_path(example) preview_path = Array(preview_paths).detect do |preview_path| Dir["#{preview_path}/#{preview_name}_preview/#{example}.html.*"].first end if preview_path.nil? raise PreviewTemplateError, "preview template for example #{example} does not exist" end path = Dir["#{preview_path}/#{preview_name}_preview/#{example}.html.*"].first Pathname.new(path) .relative_path_from(Pathname.new(preview_path)) .to_s .sub(/\..*$/, "") end