Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate safe_level of ERB.new in Ruby 2.6 #1166

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benchmarks/erb_vs_erubis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/template_erb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion lib/yard/templates/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down