From dab4b7308e0cf3873a1daa4290ab9dcae2597cbc Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Thu, 24 Nov 2022 15:46:23 -0800 Subject: [PATCH] Allow requiring erb/escape.so alone Prior to this commit, requring erb/escape first and then requiring erb did not work as expected. --- lib/erb/util.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/erb/util.rb b/lib/erb/util.rb index b6de316..9ba4583 100644 --- a/lib/erb/util.rb +++ b/lib/erb/util.rb @@ -1,3 +1,9 @@ +begin + # ERB::Util.html_escape + require 'erb/escape' +rescue LoadError # JRuby can't load .so +end + #-- # ERB::Util # @@ -15,10 +21,7 @@ module ERB::Util # # is a > 0 & a < 10? # - begin - # ERB::Util.html_escape - require 'erb/escape' - rescue LoadError + unless method_defined?(:html_escape) # for JRuby def html_escape(s) CGI.escapeHTML(s.to_s) end