summaryrefslogtreecommitdiff
path: root/lib/erb
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2022-11-24 15:49:10 -0800
committergit <svn-admin@ruby-lang.org>2022-11-24 23:49:15 +0000
commitbcdfe12919f967cad17c2c6a8c98454f373ca935 (patch)
tree59184a6cf0b3b5584e99b73710f1145221fd9260 /lib/erb
parent8ac4081aa80e571271296331dbd2a7a0654cd34a (diff)
[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.
Diffstat (limited to 'lib/erb')
-rw-r--r--lib/erb/util.rb11
1 files 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 &gt; 0 &amp; a &lt; 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