diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-09-04 23:50:10 +0900 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2023-09-05 13:47:54 +0000 |
| commit | 89a4fd67453b33b7c709c715f01cfeff8efb2f9d (patch) | |
| tree | 54793d91f75195993b6d102a69528994ba9deaef | |
| parent | e1713fa6a32070210322455d79ac4d3769aa6414 (diff) | |
[ruby/yarp] Switch `ERB.new` at startup
https://github.com/ruby/yarp/commit/b87b4450cc
| -rwxr-xr-x | yarp/templates/template.rb | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/yarp/templates/template.rb b/yarp/templates/template.rb index c661dd04e7..5880f11957 100755 --- a/yarp/templates/template.rb +++ b/yarp/templates/template.rb @@ -266,7 +266,6 @@ module YARP template = File.expand_path("../#{filepath}", __dir__) erb = read_template(template) - erb.filename = template non_ruby_heading = <<~HEADING /******************************************************************************/ @@ -305,9 +304,17 @@ module YARP def read_template(filepath) template = File.read(filepath, encoding: Encoding::UTF_8) - if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+ + erb = erb(template) + erb.filename = filepath + erb + end + + if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+ + def erb(template) ERB.new(template, trim_mode: "-") - else + end + else + def erb ERB.new(template, nil, "-") end end |
