[ruby/erb] [DOC] Make documentation 100%

https://github.com/ruby/erb/commit/9152ce8db4
This commit is contained in:
Nobuyoshi Nakada 2024-09-19 02:41:21 +09:00 committed by git
parent 46e4c86737
commit 311b9352a1
3 changed files with 12 additions and 10 deletions

View File

@ -65,9 +65,12 @@ optimized_escape_html(VALUE str)
return escaped;
}
// ERB::Util.html_escape is different from CGI.escapeHTML in the following two parts:
// * ERB::Util.html_escape converts an argument with #to_s first (only if it's not T_STRING)
// * ERB::Util.html_escape does not allocate a new string when nothing needs to be escaped
/*
* ERB::Util.html_escape is similar to CGI.escapeHTML but different in the following two parts:
*
* * ERB::Util.html_escape converts an argument with #to_s first (only if it's not T_STRING)
* * ERB::Util.html_escape does not allocate a new string when nothing needs to be escaped
*/
static VALUE
erb_escape_html(VALUE self, VALUE str)
{

View File

@ -1,5 +1,5 @@
# frozen_string_literal: true
#--
# ERB::DefMethod
#
# Utility module to define eRuby script as instance method.

View File

@ -1,9 +1,5 @@
# frozen_string_literal: true
#--
# ERB::Escape
#
# A subset of ERB::Util. Unlike ERB::Util#html_escape, we expect/hope
# Rails will not monkey-patch ERB::Escape#html_escape.
begin
# We don't build the C extension for JRuby, TruffleRuby, and WASM
if $LOAD_PATH.resolve_feature_path('erb/escape')
@ -12,6 +8,10 @@ begin
rescue LoadError # resolve_feature_path raises LoadError on TruffleRuby 22.3.0
end
unless defined?(ERB::Escape)
# ERB::Escape
#
# A subset of ERB::Util. Unlike ERB::Util#html_escape, we expect/hope
# Rails will not monkey-patch ERB::Escape#html_escape.
module ERB::Escape
def html_escape(s)
CGI.escapeHTML(s.to_s)
@ -20,7 +20,6 @@ unless defined?(ERB::Escape)
end
end
#--
# ERB::Util
#
# A utility module for conversion routines, often handy in HTML generation.