summaryrefslogtreecommitdiff
path: root/lib/erb.rb
diff options
context:
space:
mode:
authorTakashi Kokubun <[email protected]>2022-11-04 09:46:23 -0700
committergit <[email protected]>2022-11-04 16:46:29 +0000
commitb169d78c882efdb4a3da6077f6d723f65ded6f15 (patch)
tree1c9ca5641a43358e2cc4f1a554c0e6af5db924e4 /lib/erb.rb
parent13395757fa7fe0abee3a260d5669baec2dc2e0fc (diff)
[ruby/erb] Avoid using prepend + super for fallback
(https://github.com/ruby/erb/pull/28) `prepend` is prioritized more than ActiveSupport's monkey-patch, but the monkey-patch needs to work. https://github.com/ruby/erb/commit/611de5a865
Diffstat (limited to 'lib/erb.rb')
-rw-r--r--lib/erb.rb20
1 files changed, 7 insertions, 13 deletions
diff --git a/lib/erb.rb b/lib/erb.rb
index c588ae1a65..48dcca71aa 100644
--- a/lib/erb.rb
+++ b/lib/erb.rb
@@ -998,20 +998,14 @@ class ERB
#
# is a &gt; 0 &amp; a &lt; 10?
#
- def html_escape(s)
- CGI.escapeHTML(s.to_s)
+ begin
+ # ERB::Util.html_escape
+ require 'erb.so'
+ rescue LoadError
+ def html_escape(s)
+ CGI.escapeHTML(s.to_s)
+ end
end
- end
-
- begin
- require 'erb.so'
- rescue LoadError
- else
- private_constant :Escape
- Util.prepend(Escape)
- end
-
- module Util
alias h html_escape
module_function :h
module_function :html_escape