title: Ruby templates: How to pass variables into inlined ERB?
body: <p>I have an ERB template inlined into Ruby code:</p>
  
  <pre><code>require 'erb'
  
  DATA = {
      :a =&gt; "HELLO",
      :b =&gt; "WORLD",
  }
  
  template = ERB.new &lt;&lt;-EOF
      current key is: &lt;%= current %&gt;
      current value is: &lt;%= DATA[current] %&gt;
  EOF
  
  DATA.keys.each do |current|
      result = template.result
      outputFile = File.new(current.to_s,File::CREAT|File::TRUNC|File::RDWR)
      outputFile.write(result)
      outputFile.close
  end
  </code></pre>
  
  <p>I can't pass the variable "current" into the template.</p>
  
  <p>The error is:</p>
  
  <pre><code>(erb):1: undefined local variable or method `current' for main:Object (NameError)
  </code></pre>
  
  <p>How do I fix this?</p>