diff --git a/benchmarks/erb_vs_erubis.rb b/benchmarks/erb_vs_erubis.rb index 2c146107d..69cb16566 100644 --- a/benchmarks/erb_vs_erubis.rb +++ b/benchmarks/erb_vs_erubis.rb @@ -45,7 +45,7 @@ def erb_with(str, x) Erubis::TinyEruby.new(str) end x.report("erb") do eval <<-eof module YARD; module Templates; module Template - def erb_with(str, x) ERB.new(str, nil) end + def erb_with(str, x) ERB.new(str) end end end end eof diff --git a/benchmarks/template_erb.rb b/benchmarks/template_erb.rb index 1457230d2..259772b17 100644 --- a/benchmarks/template_erb.rb +++ b/benchmarks/template_erb.rb @@ -12,7 +12,7 @@ module YARD module Templates module Template def erb(section, &block) - erb = ERB.new(cache(section), nil) + erb = ERB.new(cache(section)) erb.filename = cache_filename(section).to_s erb.result(binding, &block) end diff --git a/lib/yard/templates/template.rb b/lib/yard/templates/template.rb index 2ba4c3e12..975be87c5 100644 --- a/lib/yard/templates/template.rb +++ b/lib/yard/templates/template.rb @@ -348,7 +348,11 @@ def erb_file_for(section) end def erb_with(content, filename = nil) - erb = ERB.new(content, nil, options.format == :text ? '<>' : nil) + erb = if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+ + ERB.new(content, :trim_mode => options.format == :text ? '<>' : nil) + else + ERB.new(content, nil, options.format == :text ? '<>' : nil) + end erb.filename = filename if filename erb end