From bcdfe12919f967cad17c2c6a8c98454f373ca935 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Thu, 24 Nov 2022 15:49:10 -0800 Subject: [PATCH] [ruby/erb] Allow requiring erb/escape.so alone (https://github.com/ruby/erb/pull/37) Prior to this commit, requiring 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 b6de3166d2..9ba4583f82 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