Updates. By Jeff Kreeftmeijer

How ERB uses Binding objects:

class DiyErb
  def initialize(template)
    @template = template
  end

  def result(binding)
    @template.gsub(/<%=(.+?)%>/) do
      binding.eval($1)
    end
  end
end

blog.appsignal.com/2019/01/08/ruby-magic-bindings-and-lexical-scope.html