From ed1527377aa4b4fc6947ef97b9b60f528670db47 Mon Sep 17 00:00:00 2001 From: Peter Harris Date: Fri, 3 Jan 2025 17:03:33 -0500 Subject: [PATCH] Improves caching lookup performance --- lib/rabl/sources.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/rabl/sources.rb b/lib/rabl/sources.rb index 78751432..a15c65b8 100644 --- a/lib/rabl/sources.rb +++ b/lib/rabl/sources.rb @@ -5,9 +5,11 @@ module Sources # Returns source for a given relative file # fetch_source("show", :view_path => "...") => "...contents..." def fetch_source(file, options = {}) - view_paths = Array(options[:view_path]) + Array(Rabl.configuration.view_paths) + custom_view_path = Array(options[:view_path]) + + Rabl.source_cache(file, custom_view_path) do + view_paths = custom_view_path + Array(Rabl.configuration.view_paths) - Rabl.source_cache(file, view_paths) do file_path = \ if defined?(Padrino) && context_scope.respond_to?(:settings) && context_scope.respond_to?(:resolve_template) fetch_padrino_source(file, options)