lib/sdoc/templatable.rb in sdoc-1.1.0 vs lib/sdoc/templatable.rb in sdoc-2.0.0

- old
+ new

@@ -4,10 +4,14 @@ ### Load and render the erb template in the given +templatefile+ within the ### specified +context+ (a Binding object) and return output ### Both +templatefile+ and +outfile+ should be Pathname-like objects. def eval_template(templatefile, context) template_src = templatefile.read - template = ERB.new( template_src, nil, '<>' ) + template = if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+ + ERB.new( template_src, trim_mode: '<>' ) + else + ERB.new( template_src, nil, '<>' ) + end template.filename = templatefile.to_s begin template.result( context ) rescue NoMethodError => err