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

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

https://github.com/ruby/erb/commit/1c393aa738
This commit is contained in:
Takashi Kokubun 2025-05-13 11:00:02 -07:00 committed by git
parent 735f28388c
commit 4a9d46ce07

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 # resolve_feature_path raises LoadError on TruffleRuby 22.3.0
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