From bfa2df70367578c7c2804097b6d6893485f16059 Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Mon, 26 Oct 2020 19:44:00 +0530 Subject: [PATCH 1/2] Stash exception_renderer lambda in a constant --- lib/liquid.rb | 2 ++ lib/liquid/context.rb | 2 +- lib/liquid/template.rb | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/liquid.rb b/lib/liquid.rb index e10cdf6..d452cd5 100644 --- a/lib/liquid.rb +++ b/lib/liquid.rb @@ -42,6 +42,8 @@ module Liquid TemplateParser = /(#{PartialTemplateParser}|#{AnyStartingTag})/om VariableParser = /\[[^\]]+\]|#{VariableSegment}+\??/o + EXCEPTION_RENDERER_LAMBDA = ->(_e) { raise } + singleton_class.send(:attr_accessor, :cache_classes) self.cache_classes = true end diff --git a/lib/liquid/context.rb b/lib/liquid/context.rb index 9cd869d..3667eb0 100644 --- a/lib/liquid/context.rb +++ b/lib/liquid/context.rb @@ -41,7 +41,7 @@ module Liquid self.exception_renderer = Template.default_exception_renderer if rethrow_errors - self.exception_renderer = ->(_e) { raise } + self.exception_renderer = Liquid::EXCEPTION_RENDERER_LAMBDA end # Do this last, since it could result in this object being passed to a Proc in the environment diff --git a/lib/liquid/template.rb b/lib/liquid/template.rb index 56c25d8..4e214bb 100644 --- a/lib/liquid/template.rb +++ b/lib/liquid/template.rb @@ -153,7 +153,7 @@ module Liquid c = args.shift if @rethrow_errors - c.exception_renderer = ->(_e) { raise } + c.exception_renderer = Liquid::EXCEPTION_RENDERER_LAMBDA end c From 740f8759ccbef674b6bbce1a5fbda67f52696e41 Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Wed, 28 Oct 2020 23:06:13 +0530 Subject: [PATCH 2/2] Rename constant to RAISE_EXCEPTION_LAMBDA --- lib/liquid.rb | 2 +- lib/liquid/context.rb | 2 +- lib/liquid/template.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/liquid.rb b/lib/liquid.rb index d452cd5..2833794 100644 --- a/lib/liquid.rb +++ b/lib/liquid.rb @@ -42,7 +42,7 @@ module Liquid TemplateParser = /(#{PartialTemplateParser}|#{AnyStartingTag})/om VariableParser = /\[[^\]]+\]|#{VariableSegment}+\??/o - EXCEPTION_RENDERER_LAMBDA = ->(_e) { raise } + RAISE_EXCEPTION_LAMBDA = ->(_e) { raise } singleton_class.send(:attr_accessor, :cache_classes) self.cache_classes = true diff --git a/lib/liquid/context.rb b/lib/liquid/context.rb index 3667eb0..29fa196 100644 --- a/lib/liquid/context.rb +++ b/lib/liquid/context.rb @@ -41,7 +41,7 @@ module Liquid self.exception_renderer = Template.default_exception_renderer if rethrow_errors - self.exception_renderer = Liquid::EXCEPTION_RENDERER_LAMBDA + self.exception_renderer = Liquid::RAISE_EXCEPTION_LAMBDA end # Do this last, since it could result in this object being passed to a Proc in the environment diff --git a/lib/liquid/template.rb b/lib/liquid/template.rb index 4e214bb..3009c39 100644 --- a/lib/liquid/template.rb +++ b/lib/liquid/template.rb @@ -153,7 +153,7 @@ module Liquid c = args.shift if @rethrow_errors - c.exception_renderer = Liquid::EXCEPTION_RENDERER_LAMBDA + c.exception_renderer = Liquid::RAISE_EXCEPTION_LAMBDA end c