Andrea Fazzi wrote:
> Use ERB to do templating!
> File 2: test.rb
>
> require 'erb'
>
> name = "Jack"
> File.open('test.tpl') { |file| puts ERB.new(file.read).result }

The above won't quite work; you need to pass in the binding to use
local variables from the current scope.

Here's one that does work, and slightly shorter, to boot:

File1: hello.tpl
  Hello <%=name%>

File2: test.rb
  require 'erb'
  name = "Jack"
  puts ERB.new( IO.read( 'hello.tpl' ) ).result( binding )