[ruby/erb] Reapply "Refactor the logic of require 'erb/escape'

(https://github.com/ruby/erb/pull/61)"

This reverts commit https://github.com/ruby/erb/commit/1c9200aab071.

Now that we've bumped BASERUBY, we shouldn't need to rescue the
LoadError.

https://github.com/ruby/erb/commit/846b20fe0e
This commit is contained in:
Takashi Kokubun 2025-05-13 16:29:45 -07:00 committed by git
parent 2279da2c91
commit e8e7daa71a

View File

@ -8,14 +8,11 @@
# TruffleRuby: lib/truffle/cgi/escape.rb requires 'cgi/util'.
require 'cgi/escape'
begin
# We don't build the C extension for JRuby, TruffleRuby, and WASM
if $LOAD_PATH.resolve_feature_path('erb/escape')
require 'erb/escape'
end
rescue LoadError # Ruby 3.1+ doesn't raise LoadError on resolve_feature_path, but we may use Ruby 3.0 for BASERUBY here.
end
unless defined?(ERB::Escape)
# Load or define ERB::Escape#html_escape.
# We don't build the C extention 'cgi/escape' for JRuby, TruffleRuby, and WASM.
if $LOAD_PATH.resolve_feature_path('erb/escape')
require 'erb/escape'
else
# ERB::Escape
#
# A subset of ERB::Util. Unlike ERB::Util#html_escape, we expect/hope