From 909551e4bb046b0779e075dc1a04f0c1fe54a5f3 Mon Sep 17 00:00:00 2001 From: Jordan Owens Date: Wed, 21 Aug 2019 11:16:10 -0400 Subject: [PATCH] Lookup Tilt class for template engine without loading files --- sinatra-contrib/lib/sinatra/respond_with.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sinatra-contrib/lib/sinatra/respond_with.rb b/sinatra-contrib/lib/sinatra/respond_with.rb index ed788c4b..62135cfe 100644 --- a/sinatra-contrib/lib/sinatra/respond_with.rb +++ b/sinatra-contrib/lib/sinatra/respond_with.rb @@ -169,15 +169,14 @@ module Sinatra settings.template_engines[:all].each do |engine| exts.each { |ext| possible << [engine, "#{name}.#{ext}"] } end + exts.each do |ext| settings.template_engines[ext].each { |e| possible << [e, name] } end + possible.each do |engine, template| - begin - klass = Tilt[engine] - rescue LoadError - next - end + klass = Tilt.default_mapping.template_map[engine.to_s] || + Tilt.lazy_map[engine.to_s].fetch(0, [])[0] find_template(settings.views, template, klass) do |file| next unless File.exist? file